Skip to content

Commit

Permalink
Apply mixed type param
Browse files Browse the repository at this point in the history
Signed-off-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
  • Loading branch information
samsonasik committed Oct 10, 2022
1 parent 1bfc6ff commit d108508
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 104 deletions.
29 changes: 9 additions & 20 deletions src/ArrayObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ public function __construct($input = [], $flags = self::STD_PROP_LIST, $iterator
/**
* Returns whether the requested key exists
*
* @param mixed $key
* @return bool
*/
public function __isset($key)
public function __isset(mixed $key)
{
if ($this->flag === self::ARRAY_AS_PROPS) {
return $this->offsetExists($key);
Expand All @@ -104,11 +103,9 @@ public function __isset($key)
/**
* Sets the value at the specified key to value
*
* @param mixed $key
* @param mixed $value
* @return void
*/
public function __set($key, $value)
public function __set(mixed $key, mixed $value)
{
if ($this->flag === self::ARRAY_AS_PROPS) {
$this->offsetSet($key, $value);
Expand All @@ -125,10 +122,9 @@ public function __set($key, $value)
/**
* Unsets the value at the specified key
*
* @param mixed $key
* @return void
*/
public function __unset($key)
public function __unset(mixed $key)
{
if ($this->flag === self::ARRAY_AS_PROPS) {
$this->offsetUnset($key);
Expand All @@ -145,10 +141,9 @@ public function __unset($key)
/**
* Returns the value at the specified key by reference
*
* @param mixed $key
* @return mixed
*/
public function &__get($key)
public function &__get(mixed $key)
{
if ($this->flag === self::ARRAY_AS_PROPS) {
$ret = &$this->offsetGet($key);
Expand All @@ -166,10 +161,9 @@ public function &__get($key)
/**
* Appends the value
*
* @param mixed $value
* @return void
*/
public function append($value)
public function append(mixed $value)
{
$this->storage[] = $value;
}
Expand Down Expand Up @@ -299,23 +293,21 @@ public function natsort()
/**
* Returns whether the requested key exists
*
* @param mixed $key
* @return bool
*/
#[ReturnTypeWillChange]
public function offsetExists($key)
public function offsetExists(mixed $key)
{
return isset($this->storage[$key]);
}

/**
* Returns the value at the specified key
*
* @param mixed $key
* @return mixed
*/
#[ReturnTypeWillChange]
public function &offsetGet($key)
public function &offsetGet(mixed $key)
{
$ret = null;
if (! $this->offsetExists($key)) {
Expand All @@ -329,24 +321,21 @@ public function &offsetGet($key)
/**
* Sets the value at the specified key to value
*
* @param mixed $key
* @param mixed $value
* @return void
*/
#[ReturnTypeWillChange]
public function offsetSet($key, $value)
public function offsetSet(mixed $key, mixed $value)
{
$this->storage[$key] = $value;
}

/**
* Unsets the value at the specified key
*
* @param mixed $key
* @return void
*/
#[ReturnTypeWillChange]
public function offsetUnset($key)
public function offsetUnset(mixed $key)
{
if ($this->offsetExists($key)) {
unset($this->storage[$key]);
Expand Down
1 change: 0 additions & 1 deletion src/ArraySerializableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ interface ArraySerializableInterface
/**
* Exchange internal values from provided array
*
* @param array $array
* @return void
*/
public function exchangeArray(array $array);
Expand Down
15 changes: 6 additions & 9 deletions src/ArrayUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ abstract class ArrayUtils
/**
* Test whether an array contains one or more string keys
*
* @param mixed $value
* @param bool $allowEmpty Should an empty array() return true
* @return bool
*/
public static function hasStringKeys($value, $allowEmpty = false)
public static function hasStringKeys(mixed $value, $allowEmpty = false)
{
if (! is_array($value)) {
return false;
Expand All @@ -66,11 +65,10 @@ public static function hasStringKeys($value, $allowEmpty = false)
/**
* Test whether an array contains one or more integer keys
*
* @param mixed $value
* @param bool $allowEmpty Should an empty array() return true
* @return bool
*/
public static function hasIntegerKeys($value, $allowEmpty = false)
public static function hasIntegerKeys(mixed $value, $allowEmpty = false)
{
if (! is_array($value)) {
return false;
Expand All @@ -97,7 +95,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(mixed $value, $allowEmpty = false)
{
if (! is_array($value)) {
return false;
Expand Down Expand Up @@ -130,7 +128,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(mixed $value, $allowEmpty = false)
{
if (! is_array($value)) {
return false;
Expand Down Expand Up @@ -172,7 +170,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(mixed $value, $allowEmpty = false)
{
if (! is_array($value)) {
return false;
Expand All @@ -198,7 +196,7 @@ public static function isHashTable($value, $allowEmpty = false)
* @param int|bool $strict
* @return bool
*/
public static function inArray($needle, array $haystack, $strict = false)
public static function inArray(mixed $needle, array $haystack, $strict = false)
{
if (! $strict) {
if (is_int($needle) || is_float($needle)) {
Expand Down Expand Up @@ -318,7 +316,6 @@ public static function merge(array $a, array $b, $preserveNumericKeys = false)
/**
* @deprecated Since 3.2.0; use the native array_filter methods
*
* @param array $data
* @param callable $callback
* @param null|int $flag
* @return array
Expand Down
5 changes: 1 addition & 4 deletions src/ArrayUtils/MergeReplaceKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

final class MergeReplaceKey implements MergeReplaceKeyInterface
{
/**
* @param mixed $data
*/
public function __construct(protected $data)
public function __construct(protected mixed $data)
{
}

Expand Down
8 changes: 3 additions & 5 deletions src/FastPriorityQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ public function __unserialize(array $data): void
/**
* Insert an element in the queue with a specified priority
*
* @param mixed $value
* @param int $priority
* @return void
*/
public function insert($value, $priority)
public function insert(mixed $value, $priority)
{
if (! is_int($priority)) {
throw new Exception\InvalidArgumentException('The priority must be an integer');
Expand Down Expand Up @@ -158,7 +157,7 @@ public function extract()
* @param mixed $datum
* @return bool False if the item was not found, true otherwise.
*/
public function remove($datum)
public function remove(mixed $datum)
{
$currentIndex = $this->index;
$currentSubIndex = $this->subIndex;
Expand Down Expand Up @@ -375,10 +374,9 @@ public function isEmpty()
/**
* Does the queue contain the given datum?
*
* @param mixed $datum
* @return bool
*/
public function contains($datum)
public function contains(mixed $datum)
{
foreach ($this->values as $values) {
if (in_array($datum, $values)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Guard/ArrayOrTraversableGuardTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ trait ArrayOrTraversableGuardTrait
* @throws Exception
*/
protected function guardForArrayOrTraversable(
$data,
mixed $data,
$dataName = 'Argument',
$exceptionClass = InvalidArgumentException::class
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Guard/EmptyGuardTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait EmptyGuardTrait
* @throws Exception
*/
protected function guardAgainstEmpty(
$data,
mixed $data,
$dataName = 'Argument',
$exceptionClass = InvalidArgumentException::class
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Guard/NullGuardTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait NullGuardTrait
* @throws Exception
*/
protected function guardAgainstNull(
$data,
mixed $data,
$dataName = 'Argument',
$exceptionClass = InvalidArgumentException::class
) {
Expand Down
3 changes: 1 addition & 2 deletions src/ParameterObjectInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ interface ParameterObjectInterface
{
/**
* @param string $key
* @param mixed $value
* @return void
*/
public function __set($key, $value);
public function __set($key, mixed $value);

/**
* @param string $key
Expand Down
4 changes: 1 addition & 3 deletions src/PriorityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ class PriorityList implements Iterator, Countable
* Insert a new item.
*
* @param string $name
* @param mixed $value
* @param int $priority
* @return void
*/
public function insert($name, $value, $priority = 0)
public function insert($name, mixed $value, $priority = 0)
{
if (! isset($this->items[$name])) {
$this->count++;
Expand Down Expand Up @@ -162,7 +161,6 @@ protected function sort()
* Compare the priority of two items.
*
* @param array $item1,
* @param array $item2
* @return int
*/
protected function compare(array $item1, array $item2)
Expand Down
2 changes: 1 addition & 1 deletion src/PriorityQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function insert($data, $priority = 1)
* @param mixed $datum
* @return bool False if the item was not found, true otherwise.
*/
public function remove($datum)
public function remove(mixed $datum)
{
$found = false;
$key = null;
Expand Down
6 changes: 2 additions & 4 deletions test/ArrayUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,8 @@ public function testValidArraysWithNumericKeys(array $test): void

/**
* @dataProvider invalidArrays
* @param mixed $test
*/
public function testInvalidArraysAlwaysReturnFalse($test): void
public function testInvalidArraysAlwaysReturnFalse(mixed $test): void
{
self::assertFalse(ArrayUtils::hasStringKeys($test, false));
self::assertFalse(ArrayUtils::hasIntegerKeys($test, false));
Expand Down Expand Up @@ -507,9 +506,8 @@ public function testValidIteratorsReturnArrayRepresentation(iterable $test, arra

/**
* @dataProvider invalidIterators
* @param mixed $test
*/
public function testInvalidIteratorsRaiseInvalidArgumentException($test): void
public function testInvalidIteratorsRaiseInvalidArgumentException(mixed $test): void
{
$this->expectException(InvalidArgumentException::class);
self::assertFalse(ArrayUtils::iteratorToArray($test));
Expand Down
3 changes: 1 addition & 2 deletions test/ConsoleHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public function overrideEolSequence(string $newSequence): void
$r->setValue($this->helper, $newSequence);
}

/** @param mixed $stderr */
public function overrideStderrResource($stderr): void
public function overrideStderrResource(mixed $stderr): void
{
$r = new ReflectionProperty($this->helper, 'stderr');
$r->setAccessible(true);
Expand Down
3 changes: 1 addition & 2 deletions test/StringUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ public function getUtf8StringValidity(): array

/**
* @dataProvider getUtf8StringValidity
* @param mixed $str
* @param bool $valid
*/
public function testIsValidUtf8($str, $valid): void
public function testIsValidUtf8(mixed $str, $valid): void
{
self::assertSame($valid, StringUtils::isValidUtf8($str));
}
Expand Down
9 changes: 3 additions & 6 deletions test/StringWrapper/CommonStringWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ public function convertProvider(): array
* @param string $str
* @param string $encoding
* @param string $convertEncoding
* @param mixed $expected
*/
public function testConvert($encoding, $convertEncoding, $str, $expected): void
public function testConvert($encoding, $convertEncoding, $str, mixed $expected): void
{
$wrapper = $this->getWrapper($encoding, $convertEncoding);
if (! $wrapper) {
Expand Down Expand Up @@ -221,9 +220,8 @@ public function wordWrapProvider(): array
* @param int $width
* @param string $break
* @param bool $cut
* @param mixed $expected
*/
public function testWordWrap($encoding, $string, $width, $break, $cut, $expected): void
public function testWordWrap($encoding, $string, $width, $break, $cut, mixed $expected): void
{
$wrapper = $this->getWrapper($encoding);
if (! $wrapper) {
Expand Down Expand Up @@ -284,10 +282,9 @@ public function strPadProvider(): array
* @param int $padLength
* @param string $padString
* @param int $padType
* @param mixed $expected
* @group Laminas-12186
*/
public function testStrPad($encoding, $input, $padLength, $padString, $padType, $expected): void
public function testStrPad($encoding, $input, $padLength, $padString, $padType, mixed $expected): void
{
$wrapper = $this->getWrapper($encoding);
if (! $wrapper) {
Expand Down
Loading

0 comments on commit d108508

Please sign in to comment.