From cef8fcc6e3e81b1fcbe52c8f12100d1541007b94 Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Tue, 21 May 2013 17:28:47 -0700 Subject: [PATCH] add ArrayObject This is a pure PHP implementation of ArrayObject. It does't match the reference semantics of zend's implementation, but it is much easier to build this in pure PHP, so its a good first step. It is better to have it like this, than to not have it at all. --- hphp/system/classes/arrayobject.php | 458 ++++++++++++++++++ hphp/system/classes/iterator.php | 8 +- hphp/test/slow/array_object/append.php | 5 + hphp/test/slow/array_object/append.php.expect | 24 + hphp/test/slow/array_object/asort.php | 13 + hphp/test/slow/array_object/asort.php.expect | 4 + hphp/test/slow/array_object/count.php | 12 + hphp/test/slow/array_object/count.php.expect | 2 + hphp/test/slow/array_object/exchangeArray.php | 12 + .../array_object/exchangeArray.php.expect | 19 + hphp/test/slow/array_object/getArrayCopy.php | 10 + .../slow/array_object/getArrayCopy.php.expect | 8 + hphp/test/slow/array_object/getFlags.php | 16 + .../slow/array_object/getFlags.php.expect | 2 + hphp/test/slow/array_object/getIterator.php | 14 + .../slow/array_object/getIterator.php.expect | 3 + .../slow/array_object/getIteratorClass.php | 21 + .../array_object/getIteratorClass.php.expect | 2 + hphp/test/slow/array_object/ksort.php | 13 + hphp/test/slow/array_object/ksort.php.expect | 4 + hphp/test/slow/array_object/natcasesort.php | 20 + .../slow/array_object/natcasesort.php.expect | 33 ++ hphp/test/slow/array_object/natsort.php | 13 + .../test/slow/array_object/natsort.php.expect | 29 ++ hphp/test/slow/array_object/offsetExists.php | 5 + .../slow/array_object/offsetExists.php.expect | 3 + hphp/test/slow/array_object/offsetGet.php | 5 + .../slow/array_object/offsetGet.php.expect | 3 + hphp/test/slow/array_object/offsetSet.php | 12 + .../slow/array_object/offsetSet.php.expect | 35 ++ hphp/test/slow/array_object/offsetUnset.php | 4 + .../slow/array_object/offsetUnset.php.expect | 11 + hphp/test/slow/array_object/serialize.php | 8 + .../slow/array_object/serialize.php.expect | 2 + hphp/test/slow/array_object/setFlags.php | 17 + .../slow/array_object/setFlags.php.expect | 2 + .../slow/array_object/setIteratorClass.php | 14 + .../array_object/setIteratorClass.php.expect | 12 + hphp/test/slow/array_object/uasort.php | 26 + hphp/test/slow/array_object/uasort.php.expect | 34 ++ hphp/test/slow/array_object/uksort.php | 14 + hphp/test/slow/array_object/uksort.php.expect | 4 + hphp/test/slow/array_object/unserialize.php | 10 + .../slow/array_object/unserialize.php.expect | 32 ++ .../ext-spl/arrayObject_getFlags_basic1.php | 0 .../arrayObject_getFlags_basic1.php.expectf | 0 .../ext-spl/arrayObject_setFlags_basic2.php | 0 .../arrayObject_setFlags_basic2.php.expectf | 0 .../zend/{bad => good}/ext-spl/array_004.php | 0 .../ext-spl/array_004.php.expectf | 0 .../zend/{bad => good}/ext-spl/array_016.php | 0 .../ext-spl/array_016.php.expectf | 0 .../zend/{bad => good}/ext-spl/array_021.php | 0 .../ext-spl/array_021.php.expectf | 0 .../zend/{bad => good}/ext-spl/array_024.php | 0 .../ext-spl/array_024.php.expectf | 0 .../zend/{bad => good}/ext-spl/bug28822.php | 0 .../ext-spl/bug28822.php.expectf | 0 .../zend/{bad => good}/ext-spl/bug36825.php | 0 .../ext-spl/bug36825.php.expectf | 0 .../zend/{bad => good}/ext-spl/bug40036.php | 0 .../ext-spl/bug40036.php.expectf | 0 .../zend/{bad => good}/ext-spl/bug40442.php | 0 .../ext-spl/bug40442.php.expectf | 0 .../zend/{bad => good}/ext-spl/bug54323.php | 0 .../ext-spl/bug54323.php.expectf | 0 .../zend/{bad => good}/ext-spl/bug61326.php | 0 .../ext-spl/bug61326.php.expectf | 0 .../{bad => good}/ext-spl/iterator_005.php | 0 .../ext-spl/iterator_005.php.expectf | 0 .../ext-standard-array/bug40191.php | 0 .../ext-standard-array/bug40191.php.expectf | 0 .../test/zend/{bad => good}/zend/bug42819.php | 0 .../{bad => good}/zend/bug42819.php.expectf | 0 .../zend/indirect_method_call_005.php | 0 .../zend/indirect_method_call_005.php.expectf | 0 hphp/test/zend/{bad => good}/zend/ns_035.php | 0 .../{bad => good}/zend/ns_035.php.expectf | 0 hphp/test/zend/{bad => good}/zend/ns_036.php | 0 .../{bad => good}/zend/ns_036.php.expectf | 0 .../zend/{bad => good}/zend/unset_cv10.php | 0 .../{bad => good}/zend/unset_cv10.php.expectf | 0 hphp/tools/import_zend_test.py | 10 +- 83 files changed, 999 insertions(+), 9 deletions(-) create mode 100644 hphp/system/classes/arrayobject.php create mode 100644 hphp/test/slow/array_object/append.php create mode 100644 hphp/test/slow/array_object/append.php.expect create mode 100644 hphp/test/slow/array_object/asort.php create mode 100644 hphp/test/slow/array_object/asort.php.expect create mode 100644 hphp/test/slow/array_object/count.php create mode 100644 hphp/test/slow/array_object/count.php.expect create mode 100644 hphp/test/slow/array_object/exchangeArray.php create mode 100644 hphp/test/slow/array_object/exchangeArray.php.expect create mode 100644 hphp/test/slow/array_object/getArrayCopy.php create mode 100644 hphp/test/slow/array_object/getArrayCopy.php.expect create mode 100644 hphp/test/slow/array_object/getFlags.php create mode 100644 hphp/test/slow/array_object/getFlags.php.expect create mode 100644 hphp/test/slow/array_object/getIterator.php create mode 100644 hphp/test/slow/array_object/getIterator.php.expect create mode 100644 hphp/test/slow/array_object/getIteratorClass.php create mode 100644 hphp/test/slow/array_object/getIteratorClass.php.expect create mode 100644 hphp/test/slow/array_object/ksort.php create mode 100644 hphp/test/slow/array_object/ksort.php.expect create mode 100644 hphp/test/slow/array_object/natcasesort.php create mode 100644 hphp/test/slow/array_object/natcasesort.php.expect create mode 100644 hphp/test/slow/array_object/natsort.php create mode 100644 hphp/test/slow/array_object/natsort.php.expect create mode 100644 hphp/test/slow/array_object/offsetExists.php create mode 100644 hphp/test/slow/array_object/offsetExists.php.expect create mode 100644 hphp/test/slow/array_object/offsetGet.php create mode 100644 hphp/test/slow/array_object/offsetGet.php.expect create mode 100644 hphp/test/slow/array_object/offsetSet.php create mode 100644 hphp/test/slow/array_object/offsetSet.php.expect create mode 100644 hphp/test/slow/array_object/offsetUnset.php create mode 100644 hphp/test/slow/array_object/offsetUnset.php.expect create mode 100644 hphp/test/slow/array_object/serialize.php create mode 100644 hphp/test/slow/array_object/serialize.php.expect create mode 100644 hphp/test/slow/array_object/setFlags.php create mode 100644 hphp/test/slow/array_object/setFlags.php.expect create mode 100644 hphp/test/slow/array_object/setIteratorClass.php create mode 100644 hphp/test/slow/array_object/setIteratorClass.php.expect create mode 100644 hphp/test/slow/array_object/uasort.php create mode 100644 hphp/test/slow/array_object/uasort.php.expect create mode 100644 hphp/test/slow/array_object/uksort.php create mode 100644 hphp/test/slow/array_object/uksort.php.expect create mode 100644 hphp/test/slow/array_object/unserialize.php create mode 100644 hphp/test/slow/array_object/unserialize.php.expect rename hphp/test/zend/{bad => good}/ext-spl/arrayObject_getFlags_basic1.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/arrayObject_getFlags_basic1.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/arrayObject_setFlags_basic2.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/arrayObject_setFlags_basic2.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/array_004.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/array_004.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/array_016.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/array_016.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/array_021.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/array_021.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/array_024.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/array_024.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug28822.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug28822.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug36825.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug36825.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug40036.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug40036.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug40442.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug40442.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug54323.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug54323.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug61326.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/bug61326.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-spl/iterator_005.php (100%) rename hphp/test/zend/{bad => good}/ext-spl/iterator_005.php.expectf (100%) rename hphp/test/zend/{bad => good}/ext-standard-array/bug40191.php (100%) rename hphp/test/zend/{bad => good}/ext-standard-array/bug40191.php.expectf (100%) rename hphp/test/zend/{bad => good}/zend/bug42819.php (100%) rename hphp/test/zend/{bad => good}/zend/bug42819.php.expectf (100%) rename hphp/test/zend/{bad => good}/zend/indirect_method_call_005.php (100%) rename hphp/test/zend/{bad => good}/zend/indirect_method_call_005.php.expectf (100%) rename hphp/test/zend/{bad => good}/zend/ns_035.php (100%) rename hphp/test/zend/{bad => good}/zend/ns_035.php.expectf (100%) rename hphp/test/zend/{bad => good}/zend/ns_036.php (100%) rename hphp/test/zend/{bad => good}/zend/ns_036.php.expectf (100%) rename hphp/test/zend/{bad => good}/zend/unset_cv10.php (100%) rename hphp/test/zend/{bad => good}/zend/unset_cv10.php.expectf (100%) diff --git a/hphp/system/classes/arrayobject.php b/hphp/system/classes/arrayobject.php new file mode 100644 index 000000000..16e1ab572 --- /dev/null +++ b/hphp/system/classes/arrayobject.php @@ -0,0 +1,458 @@ +storage = $input; + $this->flags = $flags; + $this->iteratorClass = $iterator_class; + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * ( excerpt from http://php.net/manual/en/arrayobject.append.php ) + * + * Appends a new value as the last element. Note: + * + * This method cannot be called when the ArrayObject was constructed from + * an object. Use ArrayObject::offsetSet() instead. + * + * @value mixed The value being appended. + * + * @return mixed No value is returned. + */ + public function append($value) { + if (!$this->isArray()) { + throw new Exception( + 'Cannot append properties to objects, '. + 'use ArrayObject::offsetSet() instead' + ); + } + $this->storage[] = $value; + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.asort.php ) + * + * Sorts the entries such that the keys maintain their correlation with + * the entries they are associated with. This is used mainly when sorting + * associative arrays where the actual element order is significant. + * + * @return mixed No value is returned. + */ + public function asort() { + return asort($this->storage); + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.count.php ) + * + * Get the number of public properties in the ArrayObject. + * + * @return mixed The number of public properties in the ArrayObject. + * Note: + * + * When the ArrayObject is constructed from an array + * all properties are public. + */ + public function count() { + return count($this->storage); + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.exchangearray.php ) + * + * Exchange the current array with another array or object. + * + * @input mixed The new array or object to exchange with the current + * array. + * + * @return mixed Returns the old array. + */ + public function exchangeArray($input) { + $old = $this->storage; + $this->storage = $input; + return $old; + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.getarraycopy.php ) + * + * Exports the ArrayObject to an array. + * + * @return mixed Returns a copy of the array. When the ArrayObject + * refers to an object an array of the public + * properties of that object will be returned. + */ + public function getArrayCopy() { + return (array) $this->storage; + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.getflags.php ) + * + * Gets the behavior flags of the ArrayObject. See the + * ArrayObject::setFlags method for a list of the available flags. + * + * @return mixed Returns the behavior flags of the ArrayObject. + */ + public function getFlags() { + return $this->flags; + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.getiterator.php ) + * + * Create a new iterator from an ArrayObject instance. + * + * @return mixed An iterator from an ArrayObject. + */ + public function getIterator() { + $class = $this->iteratorClass; + return new $class($this->storage, $this->flags); + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.getiteratorclass.php + * ) + * + * Gets the class name of the array iterator that is used by + * ArrayObject::getIterator(). + * + * @return mixed Returns the iterator class name that is used to + * iterate over this object. + */ + public function getIteratorClass() { + return $this->iteratorClass; + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.ksort.php ) + * + * Sorts the entries by key, maintaining key to entry correlations. This + * is useful mainly for associative arrays. + * + * @return mixed No value is returned. + */ + public function ksort() { + return ksort($this->storage); + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.natcasesort.php ) + * + * This method is a case insensitive version of ArrayObject::natsort. + * + * This method implements a sort algorithm that orders alphanumeric + * strings in the way a human being would while maintaining key/value + * associations. This is described as a "natural ordering". + * + * @return mixed No value is returned. + */ + public function natcasesort() { + return natcasesort($this->storage); + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.natsort.php ) + * + * This method implements a sort algorithm that orders alphanumeric + * strings in the way a human being would while maintaining key/value + * associations. This is described as a "natural ordering". An example of + * the difference between this algorithm and the regular computer string + * sorting algorithms(used in ArrayObject::asort) method can be seen in + * the example below. + * + * @return mixed No value is returned. + */ + public function natsort() { + return natsort($this->storage); + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.offsetexists.php ) + * + * + * @index mixed The index being checked. + * + * @return mixed TRUE if the requested index exists, otherwise FALSE + */ + public function offsetExists($index) { + if ($this->isArray()) { + return isset($this->storage[$index]); + } else { + return property_exists($this->storage, $index); + } + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.offsetget.php ) + * + * + * @index mixed The index with the value. + * + * @return mixed The value at the specified index or NULL. + */ + public function offsetGet($index) { + if ($this->isArray()) { + return $this->storage[$index]; + } else { + $obj = $this->storage; + return $obj->$index; + } + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.offsetset.php ) + * + * Sets the value at the specified index to newval. + * + * @index mixed The index being set. + * @newval mixed The new value for the index. + * + * @return mixed No value is returned. + */ + public function offsetSet($index, $newval) { + if ($this->isArray()) { + $this->storage[$index] = $newval; + } else { + $obj = $this->storage; + $obj->$index = $newval; + } + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.offsetunset.php ) + * + * Unsets the value at the specified index. + * + * @index mixed The index being unset. + * + * @return mixed No value is returned. + */ + public function offsetUnset($index) { + if ($this->isArray()) { + unset($this->storage[$index]); + } else { + $obj = $this->storage; + unset($obj->$index); + } + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.serialize.php ) + * + * Serializes an ArrayObject. WarningThis function is currently not + * documented; only its argument list is available. + * + * @return mixed The serialized representation of the ArrayObject. + */ + public function serialize() { + return serialize(array( + 'storage' => $this->storage, + 'flags' => $this->flags, + 'iteratorClass' => $this->iteratorClass, + )); + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.setflags.php ) + * + * Set the flags that change the behavior of the ArrayObject. + * + * @flags mixed The new ArrayObject behavior. It takes on either a + * bitmask, or named constants. Using named constants + * is strongly encouraged to ensure compatibility for + * future versions. + * + * The available behavior flags are listed below. The + * actual meanings of these flags are described in the + * predefined constants. ArrayObject behavior flags + * value constant 1 ArrayObject::STD_PROP_LIST 2 + * ArrayObject::ARRAY_AS_PROPS + * + * @return mixed No value is returned. + */ + public function setFlags(int $flags) { + $this->flags = $flags; + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.setiteratorclass.php + * ) + * + * Sets the classname of the array iterator that is used by + * ArrayObject::getIterator(). + * + * @iterator_class + * mixed The classname of the array iterator to use when + * iterating over this object. + * + * @return mixed No value is returned. + */ + public function setIteratorClass(string $iterator_class) { + $this->iteratorClass = $iterator_class; + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.uasort.php ) + * + * This function sorts the entries such that keys maintain their + * correlation with the entry that they are associated with, using a + * user-defined comparison function. + * + * This is used mainly when sorting associative arrays where the actual + * element order is significant. + * + * @cmp_function + * mixed Function cmp_function should accept two parameters + * which will be filled by pairs of entries. The + * comparison function must return an integer less + * than, equal to, or greater than zero if the first + * argument is considered to be respectively less than, + * equal to, or greater than the second. + * + * @return mixed No value is returned. + */ + public function uasort($cmp_function) { + uasort($this->storage, $cmp_function); + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.uksort.php ) + * + * This function sorts the keys of the entries using a user-supplied + * comparison function. The key to entry correlations will be maintained. + * + * @cmp_function + * mixed The callback comparison function. + * + * Function cmp_function should accept two parameters + * which will be filled by pairs of entry keys. The + * comparison function must return an integer less + * than, equal to, or greater than zero if the first + * argument is considered to be respectively less than, + * equal to, or greater than the second. + * + * @return mixed No value is returned. + */ + public function uksort($cmp_function) { + uksort($this->storage, $cmp_function); + } + +// Do NOT modifiy this doc comment block generated by idl/sysdoc.php +/** + * * excerpt from http://php.net/manual/en/arrayobject.unserialize.php ) + * + * Unserializes a serialized ArrayObject. WarningThis function is + * currently not documented; only its argument list is available. + * + * @serialized mixed The serialized ArrayObject. + * + * @return mixed The unserialized ArrayObject. + */ + public function unserialize($serialized) { + if (empty($serialized)) { + throw new UnexpectedValueException( + 'Empty serialized string cannot be empty' + ); + } + $data = unserialize($serialized); + $this->storage = $data['storage']; + $this->flags = $data['flags']; + $this->iteratorClass = $data['iteratorClass']; + } + + public function __set (string $name, $value) { + if (!$this->hasProps()) { + $this->$name = $value; + } else { + return $this->offsetSet($name, $value); + } + } + + public function __get (string $name) { + if (!$this->hasProps()) { + return $this->$name; + } else { + return $this->offsetGet($name); + } + } + + public function __isset (string $name) { + if (!$this->hasProps()) { + return isset($this->$name); + } else { + return $this->offsetExists($name); + } + } + + public function __unset (string $name) { + if (!$this->hasProps()) { + unset($this->$name); + } else { + return $this->offsetUnset($name); + } + } + + private function isArray() { + return is_array($this->storage); + } + + private function hasProps() { + return $this->flags & self::ARRAY_AS_PROPS; + } + + +} diff --git a/hphp/system/classes/iterator.php b/hphp/system/classes/iterator.php index 21ab13fb3..9cee45eb6 100644 --- a/hphp/system/classes/iterator.php +++ b/hphp/system/classes/iterator.php @@ -355,8 +355,8 @@ class ArrayIterator implements ArrayAccess, SeekableIterator, Countable { const STD_PROP_LIST = 1; const ARRAY_AS_PROPS = 2; - public function __construct($array, $flags = 0) { - $this->arr = $array; + public function __construct($array = array(), $flags = 0) { + $this->arr = (array) $array; $this->flags = $flags; reset($this->arr); } @@ -386,7 +386,7 @@ class ArrayIterator implements ArrayAccess, SeekableIterator, Countable { * @return mixed No value is returned. */ public function asort() { - return asort($this->arr, $this->flags); + return asort($this->arr); } // Do NOT modifiy this doc comment block generated by idl/sysdoc.php @@ -464,7 +464,7 @@ class ArrayIterator implements ArrayAccess, SeekableIterator, Countable { * @return mixed No value is returned. */ public function ksort() { - return ksort($this->arr, $this->flags); + return ksort($this->arr); } // Do NOT modifiy this doc comment block generated by idl/sysdoc.php diff --git a/hphp/test/slow/array_object/append.php b/hphp/test/slow/array_object/append.php new file mode 100644 index 000000000..1aa8af01b --- /dev/null +++ b/hphp/test/slow/array_object/append.php @@ -0,0 +1,5 @@ +append('fourth'); +$arrayobj->append(array('five', 'six')); +var_dump($arrayobj); diff --git a/hphp/test/slow/array_object/append.php.expect b/hphp/test/slow/array_object/append.php.expect new file mode 100644 index 000000000..4b965f840 --- /dev/null +++ b/hphp/test/slow/array_object/append.php.expect @@ -0,0 +1,24 @@ +object(ArrayObject)#1 (3) { + ["storage":"ArrayObject":private]=> + array(5) { + [0]=> + string(5) "first" + [1]=> + string(6) "second" + [2]=> + string(5) "third" + [3]=> + string(6) "fourth" + [4]=> + array(2) { + [0]=> + string(4) "five" + [1]=> + string(3) "six" + } + } + ["flags":"ArrayObject":private]=> + int(0) + ["iteratorClass":"ArrayObject":private]=> + string(13) "ArrayIterator" +} diff --git a/hphp/test/slow/array_object/asort.php b/hphp/test/slow/array_object/asort.php new file mode 100644 index 000000000..75cdf6847 --- /dev/null +++ b/hphp/test/slow/array_object/asort.php @@ -0,0 +1,13 @@ + "lemon", + "a" => "orange", + "b" => "banana", + "c" => "apple" +); +$fruitArrayObject = new ArrayObject($fruits); +$fruitArrayObject->asort(); + +foreach ($fruitArrayObject as $key => $val) { + echo "$key = $val\n"; +} diff --git a/hphp/test/slow/array_object/asort.php.expect b/hphp/test/slow/array_object/asort.php.expect new file mode 100644 index 000000000..324a3072a --- /dev/null +++ b/hphp/test/slow/array_object/asort.php.expect @@ -0,0 +1,4 @@ +c = apple +b = banana +d = lemon +a = orange diff --git a/hphp/test/slow/array_object/count.php b/hphp/test/slow/array_object/count.php new file mode 100644 index 000000000..aa9ab7891 --- /dev/null +++ b/hphp/test/slow/array_object/count.php @@ -0,0 +1,12 @@ +count()); + +$arrayobj = new ArrayObject(array('first','second','third')); +var_dump($arrayobj->count()); diff --git a/hphp/test/slow/array_object/count.php.expect b/hphp/test/slow/array_object/count.php.expect new file mode 100644 index 000000000..aa90d8965 --- /dev/null +++ b/hphp/test/slow/array_object/count.php.expect @@ -0,0 +1,2 @@ +int(1) +int(3) diff --git a/hphp/test/slow/array_object/exchangeArray.php b/hphp/test/slow/array_object/exchangeArray.php new file mode 100644 index 000000000..9c1174fd3 --- /dev/null +++ b/hphp/test/slow/array_object/exchangeArray.php @@ -0,0 +1,12 @@ + 1, "oranges" => 4, "bananas" => 5, "apples" => 10); +// Array of locations in Europe +$locations = array('Amsterdam', 'Paris', 'London'); + +$fruitsArrayObject = new ArrayObject($fruits); + +// Now exchange fruits for locations +$old = $fruitsArrayObject->exchangeArray($locations); +print_r($old); +print_r($fruitsArrayObject); diff --git a/hphp/test/slow/array_object/exchangeArray.php.expect b/hphp/test/slow/array_object/exchangeArray.php.expect new file mode 100644 index 000000000..bec1e2a43 --- /dev/null +++ b/hphp/test/slow/array_object/exchangeArray.php.expect @@ -0,0 +1,19 @@ +Array +( + [lemons] => 1 + [oranges] => 4 + [bananas] => 5 + [apples] => 10 +) +ArrayObject Object +( + [storage:ArrayObject:private] => Array + ( + [0] => Amsterdam + [1] => Paris + [2] => London + ) + + [flags:ArrayObject:private] => 0 + [iteratorClass:ArrayObject:private] => ArrayIterator +) diff --git a/hphp/test/slow/array_object/getArrayCopy.php b/hphp/test/slow/array_object/getArrayCopy.php new file mode 100644 index 000000000..e630150d9 --- /dev/null +++ b/hphp/test/slow/array_object/getArrayCopy.php @@ -0,0 +1,10 @@ + 1, "oranges" => 4, "bananas" => 5, "apples" => 10); + +$fruitsArrayObject = new ArrayObject($fruits); +$fruitsArrayObject['pears'] = 4; + +// create a copy of the array +$copy = $fruitsArrayObject->getArrayCopy(); +print_r($copy); diff --git a/hphp/test/slow/array_object/getArrayCopy.php.expect b/hphp/test/slow/array_object/getArrayCopy.php.expect new file mode 100644 index 000000000..1a74b7c0b --- /dev/null +++ b/hphp/test/slow/array_object/getArrayCopy.php.expect @@ -0,0 +1,8 @@ +Array +( + [lemons] => 1 + [oranges] => 4 + [bananas] => 5 + [apples] => 10 + [pears] => 4 +) diff --git a/hphp/test/slow/array_object/getFlags.php b/hphp/test/slow/array_object/getFlags.php new file mode 100644 index 000000000..ccaa2aaeb --- /dev/null +++ b/hphp/test/slow/array_object/getFlags.php @@ -0,0 +1,16 @@ + 1, "oranges" => 4, "bananas" => 5, "apples" => 10); + +$fruitsArrayObject = new ArrayObject($fruits); + +// Get the current flags +$flags = $fruitsArrayObject->getFlags(); +var_dump($flags); + +// Set new flags +$fruitsArrayObject->setFlags(ArrayObject::ARRAY_AS_PROPS); + +// Get the new flags +$flags = $fruitsArrayObject->getFlags(); +var_dump($flags); diff --git a/hphp/test/slow/array_object/getFlags.php.expect b/hphp/test/slow/array_object/getFlags.php.expect new file mode 100644 index 000000000..6081852c8 --- /dev/null +++ b/hphp/test/slow/array_object/getFlags.php.expect @@ -0,0 +1,2 @@ +int(0) +int(2) diff --git a/hphp/test/slow/array_object/getIterator.php b/hphp/test/slow/array_object/getIterator.php new file mode 100644 index 000000000..7b8d231c2 --- /dev/null +++ b/hphp/test/slow/array_object/getIterator.php @@ -0,0 +1,14 @@ + 'one', + '2' => 'two', + '3' => 'three'); + +$arrayobject = new ArrayObject($array); + +$iterator = $arrayobject->getIterator(); + +while($iterator->valid()) { + echo $iterator->key() . ' => ' . $iterator->current() . "\n"; + + $iterator->next(); +} diff --git a/hphp/test/slow/array_object/getIterator.php.expect b/hphp/test/slow/array_object/getIterator.php.expect new file mode 100644 index 000000000..08d1ada1a --- /dev/null +++ b/hphp/test/slow/array_object/getIterator.php.expect @@ -0,0 +1,3 @@ +1 => one +2 => two +3 => three diff --git a/hphp/test/slow/array_object/getIteratorClass.php b/hphp/test/slow/array_object/getIteratorClass.php new file mode 100644 index 000000000..5e10c1b0a --- /dev/null +++ b/hphp/test/slow/array_object/getIteratorClass.php @@ -0,0 +1,21 @@ + 1, "oranges" => 4, "bananas" => 5, "apples" => 10); + +$fruitsArrayObject = new ArrayObject($fruits); + +// Get the current class name +$className = $fruitsArrayObject->getIteratorClass(); +var_dump($className); + +// Set new classname +$fruitsArrayObject->setIteratorClass('MyArrayIterator'); + +// Get the new iterator classname +$className = $fruitsArrayObject->getIteratorClass(); +var_dump($className); diff --git a/hphp/test/slow/array_object/getIteratorClass.php.expect b/hphp/test/slow/array_object/getIteratorClass.php.expect new file mode 100644 index 000000000..ee69bbd04 --- /dev/null +++ b/hphp/test/slow/array_object/getIteratorClass.php.expect @@ -0,0 +1,2 @@ +string(13) "ArrayIterator" +string(15) "MyArrayIterator" diff --git a/hphp/test/slow/array_object/ksort.php b/hphp/test/slow/array_object/ksort.php new file mode 100644 index 000000000..8c72a2e93 --- /dev/null +++ b/hphp/test/slow/array_object/ksort.php @@ -0,0 +1,13 @@ + "lemon", + "a" => "orange", + "b" => "banana", + "c" => "apple" +); +$fruitArrayObject = new ArrayObject($fruits); +$fruitArrayObject->ksort(); + +foreach ($fruitArrayObject as $key => $val) { + echo "$key = $val\n"; +} diff --git a/hphp/test/slow/array_object/ksort.php.expect b/hphp/test/slow/array_object/ksort.php.expect new file mode 100644 index 000000000..7d13130ff --- /dev/null +++ b/hphp/test/slow/array_object/ksort.php.expect @@ -0,0 +1,4 @@ +a = orange +b = banana +c = apple +d = lemon diff --git a/hphp/test/slow/array_object/natcasesort.php b/hphp/test/slow/array_object/natcasesort.php new file mode 100644 index 000000000..f5994066d --- /dev/null +++ b/hphp/test/slow/array_object/natcasesort.php @@ -0,0 +1,20 @@ +asort(); +echo "Standard sorting\n"; +print_r($arr1); + +$arr2->natcasesort(); +echo "\nNatural order sorting (case-insensitive)\n"; +print_r($arr2); diff --git a/hphp/test/slow/array_object/natcasesort.php.expect b/hphp/test/slow/array_object/natcasesort.php.expect new file mode 100644 index 000000000..f8088f0c7 --- /dev/null +++ b/hphp/test/slow/array_object/natcasesort.php.expect @@ -0,0 +1,33 @@ +Standard sorting +ArrayObject Object +( + [storage:ArrayObject:private] => Array + ( + [0] => IMG0.png + [5] => IMG3.png + [4] => img1.png + [2] => img10.png + [1] => img12.png + [3] => img2.png + ) + + [flags:ArrayObject:private] => 0 + [iteratorClass:ArrayObject:private] => ArrayIterator +) + +Natural order sorting (case-insensitive) +ArrayObject Object +( + [storage:ArrayObject:private] => Array + ( + [0] => IMG0.png + [4] => img1.png + [3] => img2.png + [5] => IMG3.png + [2] => img10.png + [1] => img12.png + ) + + [flags:ArrayObject:private] => 0 + [iteratorClass:ArrayObject:private] => ArrayIterator +) diff --git a/hphp/test/slow/array_object/natsort.php b/hphp/test/slow/array_object/natsort.php new file mode 100644 index 000000000..7ff296413 --- /dev/null +++ b/hphp/test/slow/array_object/natsort.php @@ -0,0 +1,13 @@ +asort(); +echo "Standard sorting\n"; +print_r($arr1); + +$arr2->natsort(); +echo "\nNatural order sorting\n"; +print_r($arr2); diff --git a/hphp/test/slow/array_object/natsort.php.expect b/hphp/test/slow/array_object/natsort.php.expect new file mode 100644 index 000000000..f75a0e692 --- /dev/null +++ b/hphp/test/slow/array_object/natsort.php.expect @@ -0,0 +1,29 @@ +Standard sorting +ArrayObject Object +( + [storage:ArrayObject:private] => Array + ( + [3] => img1.png + [1] => img10.png + [0] => img12.png + [2] => img2.png + ) + + [flags:ArrayObject:private] => 0 + [iteratorClass:ArrayObject:private] => ArrayIterator +) + +Natural order sorting +ArrayObject Object +( + [storage:ArrayObject:private] => Array + ( + [3] => img1.png + [2] => img2.png + [1] => img10.png + [0] => img12.png + ) + + [flags:ArrayObject:private] => 0 + [iteratorClass:ArrayObject:private] => ArrayIterator +) diff --git a/hphp/test/slow/array_object/offsetExists.php b/hphp/test/slow/array_object/offsetExists.php new file mode 100644 index 000000000..8adc82fe8 --- /dev/null +++ b/hphp/test/slow/array_object/offsetExists.php @@ -0,0 +1,5 @@ +'e.g.')); +var_dump($arrayobj->offsetExists(1)); +var_dump($arrayobj->offsetExists('example')); +var_dump($arrayobj->offsetExists('notfound')); diff --git a/hphp/test/slow/array_object/offsetExists.php.expect b/hphp/test/slow/array_object/offsetExists.php.expect new file mode 100644 index 000000000..6b3ecdc82 --- /dev/null +++ b/hphp/test/slow/array_object/offsetExists.php.expect @@ -0,0 +1,3 @@ +bool(true) +bool(true) +bool(false) diff --git a/hphp/test/slow/array_object/offsetGet.php b/hphp/test/slow/array_object/offsetGet.php new file mode 100644 index 000000000..4785abf9c --- /dev/null +++ b/hphp/test/slow/array_object/offsetGet.php @@ -0,0 +1,5 @@ +'e.g.')); +var_dump($arrayobj->offsetGet(1)); +var_dump($arrayobj->offsetGet('example')); +var_dump($arrayobj->offsetExists('notfound')); diff --git a/hphp/test/slow/array_object/offsetGet.php.expect b/hphp/test/slow/array_object/offsetGet.php.expect new file mode 100644 index 000000000..a38b449b6 --- /dev/null +++ b/hphp/test/slow/array_object/offsetGet.php.expect @@ -0,0 +1,3 @@ +int(7) +string(4) "e.g." +bool(false) diff --git a/hphp/test/slow/array_object/offsetSet.php b/hphp/test/slow/array_object/offsetSet.php new file mode 100644 index 000000000..4f817f955 --- /dev/null +++ b/hphp/test/slow/array_object/offsetSet.php @@ -0,0 +1,12 @@ +offsetSet(4, 'four'); +$arrayobj->offsetSet('group', array('g1', 'g2')); +var_dump($arrayobj); + +$arrayobj = new ArrayObject(array('zero','one')); +$arrayobj->offsetSet(null, 'last'); +var_dump($arrayobj); diff --git a/hphp/test/slow/array_object/offsetSet.php.expect b/hphp/test/slow/array_object/offsetSet.php.expect new file mode 100644 index 000000000..259b03f66 --- /dev/null +++ b/hphp/test/slow/array_object/offsetSet.php.expect @@ -0,0 +1,35 @@ +object(ArrayObject)#1 (3) { + ["storage":"ArrayObject":private]=> + object(Example)#2 (3) { + ["property"]=> + string(11) "prop:public" + ["4"]=> + string(4) "four" + ["group"]=> + array(2) { + [0]=> + string(2) "g1" + [1]=> + string(2) "g2" + } + } + ["flags":"ArrayObject":private]=> + int(0) + ["iteratorClass":"ArrayObject":private]=> + string(13) "ArrayIterator" +} +object(ArrayObject)#3 (3) { + ["storage":"ArrayObject":private]=> + array(3) { + [0]=> + string(4) "zero" + [1]=> + string(3) "one" + [""]=> + string(4) "last" + } + ["flags":"ArrayObject":private]=> + int(0) + ["iteratorClass":"ArrayObject":private]=> + string(13) "ArrayIterator" +} diff --git a/hphp/test/slow/array_object/offsetUnset.php b/hphp/test/slow/array_object/offsetUnset.php new file mode 100644 index 000000000..5bc2f76e7 --- /dev/null +++ b/hphp/test/slow/array_object/offsetUnset.php @@ -0,0 +1,4 @@ +'zero',2=>'two')); +$arrayobj->offsetUnset(2); +var_dump($arrayobj); diff --git a/hphp/test/slow/array_object/offsetUnset.php.expect b/hphp/test/slow/array_object/offsetUnset.php.expect new file mode 100644 index 000000000..0cd18ec45 --- /dev/null +++ b/hphp/test/slow/array_object/offsetUnset.php.expect @@ -0,0 +1,11 @@ +object(ArrayObject)#1 (3) { + ["storage":"ArrayObject":private]=> + array(1) { + [0]=> + string(4) "zero" + } + ["flags":"ArrayObject":private]=> + int(0) + ["iteratorClass":"ArrayObject":private]=> + string(13) "ArrayIterator" +} diff --git a/hphp/test/slow/array_object/serialize.php b/hphp/test/slow/array_object/serialize.php new file mode 100644 index 000000000..9c33f5545 --- /dev/null +++ b/hphp/test/slow/array_object/serialize.php @@ -0,0 +1,8 @@ +serialize(); + +var_dump($s1); +var_dump($s2); diff --git a/hphp/test/slow/array_object/serialize.php.expect b/hphp/test/slow/array_object/serialize.php.expect new file mode 100644 index 000000000..aefc572c3 --- /dev/null +++ b/hphp/test/slow/array_object/serialize.php.expect @@ -0,0 +1,2 @@ +string(108) "C:11:"ArrayObject":84:{a:3:{s:7:"storage";a:0:{}s:5:"flags";i:0;s:13:"iteratorClass";s:13:"ArrayIterator";}}" +string(84) "a:3:{s:7:"storage";a:0:{}s:5:"flags";i:0;s:13:"iteratorClass";s:13:"ArrayIterator";}" diff --git a/hphp/test/slow/array_object/setFlags.php b/hphp/test/slow/array_object/setFlags.php new file mode 100644 index 000000000..39c5168ba --- /dev/null +++ b/hphp/test/slow/array_object/setFlags.php @@ -0,0 +1,17 @@ + 1, + "oranges" => 4, + "bananas" => 5, + "apples" => 10 +); + +$fruitsArrayObject = new ArrayObject($fruits); + +// Try to use array key as property +var_dump($fruitsArrayObject->lemons); +// Set the flag so that the array keys can be used as properties +$fruitsArrayObject->setFlags(ArrayObject::ARRAY_AS_PROPS); +// Try it again +var_dump($fruitsArrayObject->lemons); diff --git a/hphp/test/slow/array_object/setFlags.php.expect b/hphp/test/slow/array_object/setFlags.php.expect new file mode 100644 index 000000000..8b1946050 --- /dev/null +++ b/hphp/test/slow/array_object/setFlags.php.expect @@ -0,0 +1,2 @@ +NULL +int(1) diff --git a/hphp/test/slow/array_object/setIteratorClass.php b/hphp/test/slow/array_object/setIteratorClass.php new file mode 100644 index 000000000..ddaaf20b2 --- /dev/null +++ b/hphp/test/slow/array_object/setIteratorClass.php @@ -0,0 +1,14 @@ + 1, "oranges" => 4, "bananas" => 5, "apples" => 10); + +$fruitsArrayObject = new ArrayObject($fruits); + +// Set the iterator classname to the newly +$fruitsArrayObject->setIteratorClass('MyArrayIterator'); +print_r($fruitsArrayObject->getIterator()); diff --git a/hphp/test/slow/array_object/setIteratorClass.php.expect b/hphp/test/slow/array_object/setIteratorClass.php.expect new file mode 100644 index 000000000..5425b2b37 --- /dev/null +++ b/hphp/test/slow/array_object/setIteratorClass.php.expect @@ -0,0 +1,12 @@ +MyArrayIterator Object +( + [arr:protected] => Array + ( + [lemons] => 1 + [oranges] => 4 + [bananas] => 5 + [apples] => 10 + ) + + [flags:protected] => 0 +) diff --git a/hphp/test/slow/array_object/uasort.php b/hphp/test/slow/array_object/uasort.php new file mode 100644 index 000000000..ef62687e6 --- /dev/null +++ b/hphp/test/slow/array_object/uasort.php @@ -0,0 +1,26 @@ + 4, + 'b' => 8, + 'c' => -1, + 'd' => -9, + 'e' => 2, + 'f' => 5, + 'g' => 3, + 'h' => -4, +); +$arrayObject = new ArrayObject($array); +print_r($arrayObject); + +// Sort and print the resulting array +$arrayObject->uasort('cmp'); +print_r($arrayObject); diff --git a/hphp/test/slow/array_object/uasort.php.expect b/hphp/test/slow/array_object/uasort.php.expect new file mode 100644 index 000000000..9b6996e95 --- /dev/null +++ b/hphp/test/slow/array_object/uasort.php.expect @@ -0,0 +1,34 @@ +ArrayObject Object +( + [storage:ArrayObject:private] => Array + ( + [a] => 4 + [b] => 8 + [c] => -1 + [d] => -9 + [e] => 2 + [f] => 5 + [g] => 3 + [h] => -4 + ) + + [flags:ArrayObject:private] => 0 + [iteratorClass:ArrayObject:private] => ArrayIterator +) +ArrayObject Object +( + [storage:ArrayObject:private] => Array + ( + [d] => -9 + [h] => -4 + [c] => -1 + [e] => 2 + [g] => 3 + [a] => 4 + [f] => 5 + [b] => 8 + ) + + [flags:ArrayObject:private] => 0 + [iteratorClass:ArrayObject:private] => ArrayIterator +) diff --git a/hphp/test/slow/array_object/uksort.php b/hphp/test/slow/array_object/uksort.php new file mode 100644 index 000000000..4445e9864 --- /dev/null +++ b/hphp/test/slow/array_object/uksort.php @@ -0,0 +1,14 @@ + 1, "the Earth" => 2, "an apple" => 3, "a banana" => 4); +$arrayObject = new ArrayObject($array); +$arrayObject->uksort('cmp'); + +foreach ($arrayObject as $key => $value) { + echo "$key: $value\n"; +} diff --git a/hphp/test/slow/array_object/uksort.php.expect b/hphp/test/slow/array_object/uksort.php.expect new file mode 100644 index 000000000..65628f93c --- /dev/null +++ b/hphp/test/slow/array_object/uksort.php.expect @@ -0,0 +1,4 @@ +an apple: 3 +a banana: 4 +the Earth: 2 +John: 1 diff --git a/hphp/test/slow/array_object/unserialize.php b/hphp/test/slow/array_object/unserialize.php new file mode 100644 index 000000000..95886e347 --- /dev/null +++ b/hphp/test/slow/array_object/unserialize.php @@ -0,0 +1,10 @@ +serialize(); +$c = new ArrayObject; +$d = $c->unserialize($b); + +var_dump($a); +var_dump($c); +var_dump($d); +var_dump($a == $c); diff --git a/hphp/test/slow/array_object/unserialize.php.expect b/hphp/test/slow/array_object/unserialize.php.expect new file mode 100644 index 000000000..e8542e588 --- /dev/null +++ b/hphp/test/slow/array_object/unserialize.php.expect @@ -0,0 +1,32 @@ +object(ArrayObject)#1 (3) { + ["storage":"ArrayObject":private]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["flags":"ArrayObject":private]=> + int(0) + ["iteratorClass":"ArrayObject":private]=> + string(13) "ArrayIterator" +} +object(ArrayObject)#2 (3) { + ["storage":"ArrayObject":private]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["flags":"ArrayObject":private]=> + int(0) + ["iteratorClass":"ArrayObject":private]=> + string(13) "ArrayIterator" +} +NULL +bool(true) diff --git a/hphp/test/zend/bad/ext-spl/arrayObject_getFlags_basic1.php b/hphp/test/zend/good/ext-spl/arrayObject_getFlags_basic1.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/arrayObject_getFlags_basic1.php rename to hphp/test/zend/good/ext-spl/arrayObject_getFlags_basic1.php diff --git a/hphp/test/zend/bad/ext-spl/arrayObject_getFlags_basic1.php.expectf b/hphp/test/zend/good/ext-spl/arrayObject_getFlags_basic1.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/arrayObject_getFlags_basic1.php.expectf rename to hphp/test/zend/good/ext-spl/arrayObject_getFlags_basic1.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/arrayObject_setFlags_basic2.php b/hphp/test/zend/good/ext-spl/arrayObject_setFlags_basic2.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/arrayObject_setFlags_basic2.php rename to hphp/test/zend/good/ext-spl/arrayObject_setFlags_basic2.php diff --git a/hphp/test/zend/bad/ext-spl/arrayObject_setFlags_basic2.php.expectf b/hphp/test/zend/good/ext-spl/arrayObject_setFlags_basic2.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/arrayObject_setFlags_basic2.php.expectf rename to hphp/test/zend/good/ext-spl/arrayObject_setFlags_basic2.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/array_004.php b/hphp/test/zend/good/ext-spl/array_004.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_004.php rename to hphp/test/zend/good/ext-spl/array_004.php diff --git a/hphp/test/zend/bad/ext-spl/array_004.php.expectf b/hphp/test/zend/good/ext-spl/array_004.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_004.php.expectf rename to hphp/test/zend/good/ext-spl/array_004.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/array_016.php b/hphp/test/zend/good/ext-spl/array_016.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_016.php rename to hphp/test/zend/good/ext-spl/array_016.php diff --git a/hphp/test/zend/bad/ext-spl/array_016.php.expectf b/hphp/test/zend/good/ext-spl/array_016.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_016.php.expectf rename to hphp/test/zend/good/ext-spl/array_016.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/array_021.php b/hphp/test/zend/good/ext-spl/array_021.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_021.php rename to hphp/test/zend/good/ext-spl/array_021.php diff --git a/hphp/test/zend/bad/ext-spl/array_021.php.expectf b/hphp/test/zend/good/ext-spl/array_021.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_021.php.expectf rename to hphp/test/zend/good/ext-spl/array_021.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/array_024.php b/hphp/test/zend/good/ext-spl/array_024.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_024.php rename to hphp/test/zend/good/ext-spl/array_024.php diff --git a/hphp/test/zend/bad/ext-spl/array_024.php.expectf b/hphp/test/zend/good/ext-spl/array_024.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_024.php.expectf rename to hphp/test/zend/good/ext-spl/array_024.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/bug28822.php b/hphp/test/zend/good/ext-spl/bug28822.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug28822.php rename to hphp/test/zend/good/ext-spl/bug28822.php diff --git a/hphp/test/zend/bad/ext-spl/bug28822.php.expectf b/hphp/test/zend/good/ext-spl/bug28822.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug28822.php.expectf rename to hphp/test/zend/good/ext-spl/bug28822.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/bug36825.php b/hphp/test/zend/good/ext-spl/bug36825.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug36825.php rename to hphp/test/zend/good/ext-spl/bug36825.php diff --git a/hphp/test/zend/bad/ext-spl/bug36825.php.expectf b/hphp/test/zend/good/ext-spl/bug36825.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug36825.php.expectf rename to hphp/test/zend/good/ext-spl/bug36825.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/bug40036.php b/hphp/test/zend/good/ext-spl/bug40036.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug40036.php rename to hphp/test/zend/good/ext-spl/bug40036.php diff --git a/hphp/test/zend/bad/ext-spl/bug40036.php.expectf b/hphp/test/zend/good/ext-spl/bug40036.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug40036.php.expectf rename to hphp/test/zend/good/ext-spl/bug40036.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/bug40442.php b/hphp/test/zend/good/ext-spl/bug40442.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug40442.php rename to hphp/test/zend/good/ext-spl/bug40442.php diff --git a/hphp/test/zend/bad/ext-spl/bug40442.php.expectf b/hphp/test/zend/good/ext-spl/bug40442.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug40442.php.expectf rename to hphp/test/zend/good/ext-spl/bug40442.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/bug54323.php b/hphp/test/zend/good/ext-spl/bug54323.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug54323.php rename to hphp/test/zend/good/ext-spl/bug54323.php diff --git a/hphp/test/zend/bad/ext-spl/bug54323.php.expectf b/hphp/test/zend/good/ext-spl/bug54323.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug54323.php.expectf rename to hphp/test/zend/good/ext-spl/bug54323.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/bug61326.php b/hphp/test/zend/good/ext-spl/bug61326.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug61326.php rename to hphp/test/zend/good/ext-spl/bug61326.php diff --git a/hphp/test/zend/bad/ext-spl/bug61326.php.expectf b/hphp/test/zend/good/ext-spl/bug61326.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug61326.php.expectf rename to hphp/test/zend/good/ext-spl/bug61326.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_005.php b/hphp/test/zend/good/ext-spl/iterator_005.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_005.php rename to hphp/test/zend/good/ext-spl/iterator_005.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_005.php.expectf b/hphp/test/zend/good/ext-spl/iterator_005.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_005.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_005.php.expectf diff --git a/hphp/test/zend/bad/ext-standard-array/bug40191.php b/hphp/test/zend/good/ext-standard-array/bug40191.php similarity index 100% rename from hphp/test/zend/bad/ext-standard-array/bug40191.php rename to hphp/test/zend/good/ext-standard-array/bug40191.php diff --git a/hphp/test/zend/bad/ext-standard-array/bug40191.php.expectf b/hphp/test/zend/good/ext-standard-array/bug40191.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-standard-array/bug40191.php.expectf rename to hphp/test/zend/good/ext-standard-array/bug40191.php.expectf diff --git a/hphp/test/zend/bad/zend/bug42819.php b/hphp/test/zend/good/zend/bug42819.php similarity index 100% rename from hphp/test/zend/bad/zend/bug42819.php rename to hphp/test/zend/good/zend/bug42819.php diff --git a/hphp/test/zend/bad/zend/bug42819.php.expectf b/hphp/test/zend/good/zend/bug42819.php.expectf similarity index 100% rename from hphp/test/zend/bad/zend/bug42819.php.expectf rename to hphp/test/zend/good/zend/bug42819.php.expectf diff --git a/hphp/test/zend/bad/zend/indirect_method_call_005.php b/hphp/test/zend/good/zend/indirect_method_call_005.php similarity index 100% rename from hphp/test/zend/bad/zend/indirect_method_call_005.php rename to hphp/test/zend/good/zend/indirect_method_call_005.php diff --git a/hphp/test/zend/bad/zend/indirect_method_call_005.php.expectf b/hphp/test/zend/good/zend/indirect_method_call_005.php.expectf similarity index 100% rename from hphp/test/zend/bad/zend/indirect_method_call_005.php.expectf rename to hphp/test/zend/good/zend/indirect_method_call_005.php.expectf diff --git a/hphp/test/zend/bad/zend/ns_035.php b/hphp/test/zend/good/zend/ns_035.php similarity index 100% rename from hphp/test/zend/bad/zend/ns_035.php rename to hphp/test/zend/good/zend/ns_035.php diff --git a/hphp/test/zend/bad/zend/ns_035.php.expectf b/hphp/test/zend/good/zend/ns_035.php.expectf similarity index 100% rename from hphp/test/zend/bad/zend/ns_035.php.expectf rename to hphp/test/zend/good/zend/ns_035.php.expectf diff --git a/hphp/test/zend/bad/zend/ns_036.php b/hphp/test/zend/good/zend/ns_036.php similarity index 100% rename from hphp/test/zend/bad/zend/ns_036.php rename to hphp/test/zend/good/zend/ns_036.php diff --git a/hphp/test/zend/bad/zend/ns_036.php.expectf b/hphp/test/zend/good/zend/ns_036.php.expectf similarity index 100% rename from hphp/test/zend/bad/zend/ns_036.php.expectf rename to hphp/test/zend/good/zend/ns_036.php.expectf diff --git a/hphp/test/zend/bad/zend/unset_cv10.php b/hphp/test/zend/good/zend/unset_cv10.php similarity index 100% rename from hphp/test/zend/bad/zend/unset_cv10.php rename to hphp/test/zend/good/zend/unset_cv10.php diff --git a/hphp/test/zend/bad/zend/unset_cv10.php.expectf b/hphp/test/zend/good/zend/unset_cv10.php.expectf similarity index 100% rename from hphp/test/zend/bad/zend/unset_cv10.php.expectf rename to hphp/test/zend/good/zend/unset_cv10.php.expectf diff --git a/hphp/tools/import_zend_test.py b/hphp/tools/import_zend_test.py index 46f1c03a9..4f69e72c2 100755 --- a/hphp/tools/import_zend_test.py +++ b/hphp/tools/import_zend_test.py @@ -331,7 +331,7 @@ parser.add_argument( "--only", type=str, action='append', - help="only import tests whose path matches this regex." + help="only import tests whose path contains this substring." ) parser.add_argument( "--dirty", @@ -592,11 +592,11 @@ if args.zend_path: for filename in files: full_file = os.path.join(root, filename) - def matches(regexes): - if not regexes: + def matches(patterns): + if not patterns: return True - for regex in regexes: - if re.search(regex, full_file): + for pattern in patterns: + if pattern in full_file: return True return False