Skip to content

Commit

Permalink
Replaces docblock type hints with code typehints in Array util classes
Browse files Browse the repository at this point in the history
Signed-off-by: Carnage <[email protected]>
  • Loading branch information
carnage committed Jul 24, 2021
1 parent bf7ddb3 commit 8e37a3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
10 changes: 3 additions & 7 deletions src/ArrayObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Count
* Constructor
*
* @param array|object $input Object values must act like ArrayAccess
* @param int $flags
* @param string $iteratorClass
*/
public function __construct($input = [], $flags = self::STD_PROP_LIST, $iteratorClass = 'ArrayIterator')
public function __construct($input = [], int $flags = self::STD_PROP_LIST, string $iteratorClass = 'ArrayIterator')
{
$this->setFlags($flags);
$this->storage = $input;
Expand Down Expand Up @@ -351,21 +349,19 @@ public function serialize()
/**
* Sets the behavior flags
*
* @param int $flags
* @return void
*/
public function setFlags($flags)
public function setFlags(int $flags)
{
$this->flag = $flags;
}

/**
* Sets the iterator classname for the ArrayObject
*
* @param string $class
* @return void
*/
public function setIteratorClass($class)
public function setIteratorClass(string $class)
{
if (class_exists($class)) {
$this->iteratorClass = $class;
Expand Down
18 changes: 8 additions & 10 deletions src/ArrayUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract class ArrayUtils
* @param bool $allowEmpty Should an empty array() return true
* @return bool
*/
public static function hasStringKeys($value, $allowEmpty = false)
public static function hasStringKeys($value, bool $allowEmpty = false)
{
if (! is_array($value)) {
return false;
Expand All @@ -69,7 +69,7 @@ public static function hasStringKeys($value, $allowEmpty = false)
* @param bool $allowEmpty Should an empty array() return true
* @return bool
*/
public static function hasIntegerKeys($value, $allowEmpty = false)
public static function hasIntegerKeys($value, bool $allowEmpty = false)
{
if (! is_array($value)) {
return false;
Expand All @@ -96,7 +96,7 @@ public static function hasIntegerKeys($value, $allowEmpty = false)
* @param bool $allowEmpty Should an empty array() return true
* @return bool
*/
public static function hasNumericKeys($value, $allowEmpty = false)
public static function hasNumericKeys($value, bool $allowEmpty = false)
{
if (! is_array($value)) {
return false;
Expand Down Expand Up @@ -129,7 +129,7 @@ public static function hasNumericKeys($value, $allowEmpty = false)
* @param bool $allowEmpty Is an empty list a valid list?
* @return bool
*/
public static function isList($value, $allowEmpty = false)
public static function isList($value, bool $allowEmpty = false)
{
if (! is_array($value)) {
return false;
Expand Down Expand Up @@ -171,7 +171,7 @@ public static function isList($value, $allowEmpty = false)
* @param bool $allowEmpty Is an empty array() a valid hash table?
* @return bool
*/
public static function isHashTable($value, $allowEmpty = false)
public static function isHashTable($value, bool $allowEmpty = false)
{
if (! is_array($value)) {
return false;
Expand Down Expand Up @@ -226,7 +226,7 @@ public static function inArray($needle, array $haystack, $strict = false)
* @throws Exception\InvalidArgumentException If $iterator is not an array or a Traversable object.
* @return array
*/
public static function iteratorToArray($iterator, $recursive = true)
public static function iteratorToArray($iterator, bool $recursive = true)
{
if (! is_array($iterator) && ! $iterator instanceof Traversable) {
throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable object');
Expand Down Expand Up @@ -276,10 +276,9 @@ public static function iteratorToArray($iterator, $recursive = true)
*
* @param array $a
* @param array $b
* @param bool $preserveNumericKeys
* @return array
*/
public static function merge(array $a, array $b, $preserveNumericKeys = false)
public static function merge(array $a, array $b, bool $preserveNumericKeys = false)
{
foreach ($b as $key => $value) {
if ($value instanceof MergeReplaceKeyInterface) {
Expand Down Expand Up @@ -309,11 +308,10 @@ public static function merge(array $a, array $b, $preserveNumericKeys = false)
*
* @param array $data
* @param callable $callback
* @param null|int $flag
* @return array
* @throws Exception\InvalidArgumentException
*/
public static function filter(array $data, $callback, $flag = null)
public static function filter(array $data, $callback, ?int $flag = null)
{
if (! is_callable($callback)) {
throw new Exception\InvalidArgumentException(sprintf(
Expand Down

0 comments on commit 8e37a3b

Please sign in to comment.