From 385ed65801728c65c0fe61d4450f3e67e44c80ba Mon Sep 17 00:00:00 2001 From: Vassil Mladenov Date: Thu, 6 Feb 2020 10:14:02 -0800 Subject: [PATCH] Remove array(...) literals from hphp/system Reviewed By: billf Differential Revision: D19673045 fbshipit-source-id: 92e971a7b0ccbff43518417e11edb6528da3adb1 --- hphp/system/php/apc/APCIterator.php | 2 +- hphp/system/php/async/vm.ns.php | 2 +- hphp/system/php/filter/filter_var_array.php | 8 ++++---- hphp/system/php/lang/BaseException.ns.php | 4 ++-- hphp/system/php/redis/Redis.php | 6 +++--- hphp/system/php/spl/datastructures/SplDoublyLinkedList.php | 4 ++-- hphp/system/php/spl/datastructures/SplFixedArray.php | 2 +- hphp/system/php/spl/datastructures/SplObjectStorage.php | 10 +++++----- hphp/system/php/spl/datastructures/SplPriorityQueue.php | 2 +- hphp/system/php/spl/iterators/AppendIterator.php | 4 ++-- hphp/system/php/spl/iterators/FilterIterator.php | 2 +- hphp/system/php/spl/iterators/IteratorIterator.php | 2 +- hphp/system/php/spl/iterators/MultipleIterator.php | 4 ++-- hphp/system/php/spl/iterators/RecursiveIteratorIterator.php | 10 +++++----- hphp/system/php/spl/iterators/RecursiveTreeIterator.php | 4 ++-- 15 files changed, 33 insertions(+), 33 deletions(-) diff --git a/hphp/system/php/apc/APCIterator.php b/hphp/system/php/apc/APCIterator.php index ea2704591ae..827f24b5e8e 100644 --- a/hphp/system/php/apc/APCIterator.php +++ b/hphp/system/php/apc/APCIterator.php @@ -115,7 +115,7 @@ class APCIterator implements Iterator{ public function current() { if (!$this->valid()) return false; $info = $this->getInfo()[$this->index]; - $ret = array(); + $ret = darray[]; if ($this->format & APC_ITER_TYPE) { $ret['type'] = ($info['type'] == 0) ? 'user' : 'file'; } diff --git a/hphp/system/php/async/vm.ns.php b/hphp/system/php/async/vm.ns.php index fe017a90f00..de25d91897e 100644 --- a/hphp/system/php/async/vm.ns.php +++ b/hphp/system/php/async/vm.ns.php @@ -91,7 +91,7 @@ async function v( */ async function va(...$awaitables): Awaitable/*<(...)>*/ { await AwaitAllWaitHandle::fromArray($awaitables); - $ret = array(); + $ret = varray[]; foreach ($awaitables as $value) { $ret[] = \HH\Asio\result($value); } diff --git a/hphp/system/php/filter/filter_var_array.php b/hphp/system/php/filter/filter_var_array.php index b46d2465466..0d1b1e89fc5 100644 --- a/hphp/system/php/filter/filter_var_array.php +++ b/hphp/system/php/filter/filter_var_array.php @@ -15,7 +15,7 @@ abstract final class _FilterVarArrayFilterValidator { } <<__Rx>> -function _filter_var_array_single($value, $filter, $options = array()) { +function _filter_var_array_single($value, $filter, $options = darray[]) { if (!_FilterVarArrayFilterValidator::isValid($filter)) { $filter = FILTER_DEFAULT; } @@ -23,13 +23,13 @@ function _filter_var_array_single($value, $filter, $options = array()) { $flags = isset($options['flags']) ? $options['flags'] : 0; if ($flags & FILTER_FORCE_ARRAY && !is_array($ret)) { - return array($ret); + return varray[$ret]; } if ($flags & FILTER_REQUIRE_SCALAR && is_array($ret)) { return false; } if ($flags & FILTER_REQUIRE_ARRAY && is_null($ret)) { - return array(); + return varray[]; } return $ret; @@ -88,7 +88,7 @@ function filter_var_array($data, $definition = null, $add_empty = true) { $definition = array_fill_keys(array_keys($data), null); } - $ret = array(); + $ret = darray[]; foreach ($definition as $key => $def) { if ($key === "") { trigger_error( diff --git a/hphp/system/php/lang/BaseException.ns.php b/hphp/system/php/lang/BaseException.ns.php index ba817c7cc5f..85ece592e3d 100644 --- a/hphp/system/php/lang/BaseException.ns.php +++ b/hphp/system/php/lang/BaseException.ns.php @@ -56,7 +56,7 @@ trait BaseException { final public function setPreviousChain(\Throwable $previous) { $cur = $this; - $cycle = array(); + $cycle = darray[]; $cycle[\spl_object_hash($cur)] = true; $next = $cur->getPrevious(); while ($next is \Throwable && @@ -196,7 +196,7 @@ trait BaseException { */ public function toString() { $res = ""; - $lst = array(); + $lst = darray[]; $ex = $this; while ($ex != null && !\array_key_exists(\spl_object_hash($ex), $lst)) { $lst[\spl_object_hash($ex)] = $ex; diff --git a/hphp/system/php/redis/Redis.php b/hphp/system/php/redis/Redis.php index 83f09573f4c..0894779432e 100644 --- a/hphp/system/php/redis/Redis.php +++ b/hphp/system/php/redis/Redis.php @@ -575,7 +575,7 @@ class Redis { */ if ($flat === false) return $flat; assert(count($flat) % 2 == 0); - $ret = array(); + $ret = darray[]; for ($i = 0; $i < count($flat); $i += 2) $ret[$flat[$i]] = $flat[$i + 1]; return $ret; } @@ -590,7 +590,7 @@ class Redis { * keys to values. */ assert(count($flat) % 2 == 0); - $ret = array(); + $ret = darray[]; for ($i = 0; $i < count($flat); $i += 2) $ret[$flat[$i]] = $flat[$i + 1]; return $ret; } @@ -1715,7 +1715,7 @@ class Redis { $errstr = null; if ($persistent) { if ($persistent_id ?? false) { - $pid = array('id' => array('persistent_id' => $persistent_id)); + $pid = darray['id' => darray['persistent_id' => $persistent_id]]; $context = stream_context_create($pid); $sok = $host; if ($port > 0) $sok .= ':' . $port; diff --git a/hphp/system/php/spl/datastructures/SplDoublyLinkedList.php b/hphp/system/php/spl/datastructures/SplDoublyLinkedList.php index 99e612f3cbc..fe4a24b5556 100644 --- a/hphp/system/php/spl/datastructures/SplDoublyLinkedList.php +++ b/hphp/system/php/spl/datastructures/SplDoublyLinkedList.php @@ -493,11 +493,11 @@ class SplDoublyLinkedList * @return mixed The serialized string. */ public function serialize() { - $data = array(); + $data = varray[]; foreach ($this as $val) { $data[] = $val; } - return serialize(array($data, $this->mode)); + return serialize(varray[$data, $this->mode]); } // This doc comment block generated by idl/sysdoc.php diff --git a/hphp/system/php/spl/datastructures/SplFixedArray.php b/hphp/system/php/spl/datastructures/SplFixedArray.php index 0ca6aaa8a89..bcf2bde461c 100644 --- a/hphp/system/php/spl/datastructures/SplFixedArray.php +++ b/hphp/system/php/spl/datastructures/SplFixedArray.php @@ -13,7 +13,7 @@ */ class SplFixedArray implements \HH\Iterator, ArrayAccess, Countable { - protected $data = array(); + protected $data = varray[]; // This doc comment block generated by idl/sysdoc.php /** diff --git a/hphp/system/php/spl/datastructures/SplObjectStorage.php b/hphp/system/php/spl/datastructures/SplObjectStorage.php index b11403424cb..75f3e426267 100644 --- a/hphp/system/php/spl/datastructures/SplObjectStorage.php +++ b/hphp/system/php/spl/datastructures/SplObjectStorage.php @@ -12,7 +12,7 @@ class SplObjectStorage implements \HH\Iterator, Countable, Serializable, ArrayAccess { - private $__storage = array(); + private $__storage = darray[]; private $__key = 0; // This doc comment block generated by idl/sysdoc.php @@ -129,9 +129,9 @@ class SplObjectStorage */ public function attach($obj, $data = null) { if (gettype($obj) === 'object') { - $this->__storage[$this->getHashAndValidate($obj)] = array( + $this->__storage[$this->getHashAndValidate($obj)] = darray[ 'obj' => $obj, 'inf' => $data - ); + ]; } } @@ -237,7 +237,7 @@ class SplObjectStorage * @return mixed No value is returned. */ public function removeAll($storage) { - $cache = array(); + $cache = varray[]; foreach ($storage as $obj) { $cache[] = $obj; } @@ -260,7 +260,7 @@ class SplObjectStorage * @return mixed No value is returned. */ public function removeAllExcept($storage) { - $cache = array(); + $cache = varray[]; foreach ($this->__storage as $object) { if (!$storage->contains($object['obj'])) { $cache[] = $object['obj']; diff --git a/hphp/system/php/spl/datastructures/SplPriorityQueue.php b/hphp/system/php/spl/datastructures/SplPriorityQueue.php index 998808b0bc8..5c055e0e099 100644 --- a/hphp/system/php/spl/datastructures/SplPriorityQueue.php +++ b/hphp/system/php/spl/datastructures/SplPriorityQueue.php @@ -109,7 +109,7 @@ class SplPriorityQueue implements \HH\Iterator, Countable { * @return mixed No value is returned. */ public function insert($value, $priority) { - $data = array('data' => $value, 'priority' => $priority); + $data = darray['data' => $value, 'priority' => $priority]; return $this->getHeap()->insert($data); } diff --git a/hphp/system/php/spl/iterators/AppendIterator.php b/hphp/system/php/spl/iterators/AppendIterator.php index 00a1d2b7601..a3ea92e7a0e 100644 --- a/hphp/system/php/spl/iterators/AppendIterator.php +++ b/hphp/system/php/spl/iterators/AppendIterator.php @@ -19,7 +19,7 @@ class AppendIterator extends IteratorIterator implements OuterIterator { * @return mixed No value is returned. */ public function __construct() { - $this->iterators = new ArrayIterator(array()); + $this->iterators = new ArrayIterator(varray[]); } // This doc comment block generated by idl/sysdoc.php @@ -178,7 +178,7 @@ class AppendIterator extends IteratorIterator implements OuterIterator { } public function __call($func, $params) { - return call_user_func_array(array($this->getInnerIterator(), $func), + return call_user_func_array(varray[$this->getInnerIterator(), $func], $params); } } diff --git a/hphp/system/php/spl/iterators/FilterIterator.php b/hphp/system/php/spl/iterators/FilterIterator.php index 92a0bc65701..ae7f42a53e1 100644 --- a/hphp/system/php/spl/iterators/FilterIterator.php +++ b/hphp/system/php/spl/iterators/FilterIterator.php @@ -124,7 +124,7 @@ abstract class FilterIterator extends IteratorIterator { } public function __call($func, $params) { - return call_user_func_array(array($this->it, $func), $params); + return call_user_func_array(varray[$this->it, $func], $params); } } diff --git a/hphp/system/php/spl/iterators/IteratorIterator.php b/hphp/system/php/spl/iterators/IteratorIterator.php index 67664b40e90..f9b45db403b 100644 --- a/hphp/system/php/spl/iterators/IteratorIterator.php +++ b/hphp/system/php/spl/iterators/IteratorIterator.php @@ -123,7 +123,7 @@ class IteratorIterator implements OuterIterator { } public function __call($func, $params) { - return call_user_func_array(array($this->iterator, $func), $params); + return call_user_func_array(varray[$this->iterator, $func], $params); } /** diff --git a/hphp/system/php/spl/iterators/MultipleIterator.php b/hphp/system/php/spl/iterators/MultipleIterator.php index fb5d617008a..032645f97da 100644 --- a/hphp/system/php/spl/iterators/MultipleIterator.php +++ b/hphp/system/php/spl/iterators/MultipleIterator.php @@ -127,7 +127,7 @@ class MultipleIterator implements Iterator { if (!sizeof($this->iterators)) { return false; } - $retval = array(); + $retval = darray[]; foreach($this->iterators as $iter) { if ($iter->valid()) { if ($this->flags & self::MIT_KEYS_ASSOC) { @@ -159,7 +159,7 @@ class MultipleIterator implements Iterator { if (!sizeof($this->iterators)) { return false; } - $retval = array(); + $retval = varray[]; foreach($this->iterators as $iter) { if ($iter->valid()) { $retval[] = $iter->key(); diff --git a/hphp/system/php/spl/iterators/RecursiveIteratorIterator.php b/hphp/system/php/spl/iterators/RecursiveIteratorIterator.php index 18767272a4f..f5004495e37 100644 --- a/hphp/system/php/spl/iterators/RecursiveIteratorIterator.php +++ b/hphp/system/php/spl/iterators/RecursiveIteratorIterator.php @@ -24,7 +24,7 @@ class RecursiveIteratorIterator implements OuterIterator { const NEXT_COMPLETE = 10; const NEXT_REPEAT = 11; - private $iterators = array(); + private $iterators = varray[]; private $originalIterator; private $mode; private $flags; @@ -70,7 +70,7 @@ class RecursiveIteratorIterator implements OuterIterator { "it is required" ); } - $this->iterators[] = array($iterator, self::STATE_START); + $this->iterators[] = varray[$iterator, self::STATE_START]; $this->originalIterator = $iterator; $this->mode = (int) $mode; $this->flags = $flags; @@ -219,7 +219,7 @@ class RecursiveIteratorIterator implements OuterIterator { $this->setInnerIteratorState(self::STATE_NEXT); } $children->rewind(); - $this->iterators[] = array($children, self::STATE_START); + $this->iterators[] = varray[$children, self::STATE_START]; $this->beginChildren(); return self::NEXT_REPEAT; } @@ -242,7 +242,7 @@ class RecursiveIteratorIterator implements OuterIterator { } $it = $this->originalIterator; - $this->iterators = array(array($it, self::STATE_START)); + $this->iterators = varray[varray[$it, self::STATE_START]]; $it->rewind(); if (!$this->inIteration) { $this->beginIteration(); @@ -406,7 +406,7 @@ class RecursiveIteratorIterator implements OuterIterator { */ public function __call($func, $params) { return call_user_func_array( - array($this->getInnerIterator(), $func), + varray[$this->getInnerIterator(), $func], $params ); } diff --git a/hphp/system/php/spl/iterators/RecursiveTreeIterator.php b/hphp/system/php/spl/iterators/RecursiveTreeIterator.php index 41d0fcfdfbd..18e1a92c070 100644 --- a/hphp/system/php/spl/iterators/RecursiveTreeIterator.php +++ b/hphp/system/php/spl/iterators/RecursiveTreeIterator.php @@ -23,14 +23,14 @@ class RecursiveTreeIterator extends RecursiveIteratorIterator private $flags; - private $prefix = array( + private $prefix = varray[ "", // PREFIX_LEFT "| ", // PREFIX_MID_HAS_NEXT " ", // PREFIX_MID_LAST "|-", // PREFIX_END_HAS_NEXT "\\-", // PREFIX_END_LAST "", // PREFIX_RIGHT - ); + ]; private $postfix = ""; -- 2.11.4.GIT