diff --git a/phpstan.neon b/phpstan.neon
index a5290dc..6faf6f5 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,31 +1,13 @@
parameters:
level: 8
- reportUnmatchedIgnoredErrors: false
+ reportUnmatchedIgnoredErrors: true
paths:
- %currentWorkingDirectory%/src/
- %currentWorkingDirectory%/tests/
ignoreErrors:
-
- message: ~has no return type specified~
+ identifier: missingType.return
path: %currentWorkingDirectory%/tests/*
-
message: '#assertContains|assertInternalType|assertStringContainsString|assertIsArray|expectExceptionMessage#'
path: %currentWorkingDirectory%/tests/*
- -
- message: ~Call to an undefined static method~
- path: %currentWorkingDirectory%/tests/StaticArrayyTest.php
- # false-positive?
- - '/function call_user_func expects callable.*array\{.*\} given/'
- - '/function call_user_func_array expects callable.*array\{.*\} given/'
- - '/\(array\) does not accept array\) does not accept array/'
- - '/\(array\) does not accept array/'
- - '/array_map expects \(callable\(mixed\):/'
- # ignore gernal errors
- - '/Unsafe usage of new static/'
- - '/should be compatible with return type \(bool\) of method ArrayObject/'
- # ignore Iterator stuff
- - '/__construct\(\) has parameter \$iteratorClass with generic/'
- - '/create\(\) has parameter \$iteratorClass with generic/'
- - '/parameter \$iteratorClass with generic class Arrayy\\ArrayyIterator/'
- - '/generic class Arrayy\\ArrayyIterator does not specify its types/'
diff --git a/src/Arrayy.php b/src/Arrayy.php
index 2e71090..5ddf44c 100644
--- a/src/Arrayy.php
+++ b/src/Arrayy.php
@@ -59,7 +59,7 @@ class Arrayy extends \ArrayObject implements \IteratorAggregate, \ArrayAccess, \
/**
* @var string
*
- * @phpstan-var class-string<\Arrayy\ArrayyIterator>
+ * @phpstan-var class-string<\Arrayy\ArrayyIterator>
*/
protected $iteratorClass = ArrayyIterator::class;
@@ -111,7 +111,7 @@ class Arrayy extends \ArrayObject implements \IteratorAggregate, \ArrayAccess, \
* true, otherwise this option didn't not work anyway.
*
*
- * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
*/
public function __construct(
$data = [],
@@ -314,7 +314,7 @@ public function append($value, $key = null): self
&&
\is_array($this->array[$key])
) {
- $this->array[$key][] = $value;
+ $this->array[$key][] = $value; // @phpstan-ignore assign.propertyType
} else {
$this->array[$key] = $value;
}
@@ -900,7 +900,7 @@ public function serialize(): string
*
* @return void
*
- * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
*/
#[\ReturnTypeWillChange]
public function setIteratorClass($iteratorClass)
@@ -1734,7 +1734,7 @@ public function countValues(): self
* @return static
* (Immutable) Returns an new instance of the Arrayy object.
*
- * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
* @phpstan-return static
* @psalm-mutation-free
*/
@@ -1743,7 +1743,7 @@ public static function create(
string $iteratorClass = ArrayyIterator::class,
bool $checkPropertiesInConstructor = true
) {
- return new static(
+ return new static( // @phpstan-ignore new.static
$data,
$iteratorClass,
$checkPropertiesInConstructor
@@ -1893,7 +1893,7 @@ public static function createFromArray(array $array): self
public static function createFromObject(\Traversable $object): self
{
// init
- $arrayy = new static();
+ $arrayy = static::create();
if ($object instanceof self) {
$objectArray = $object->getGenerator();
@@ -5050,7 +5050,7 @@ public function prepend($value, $key = null)
if ($key === null) {
\array_unshift($this->array, $value);
} else {
- $this->array = [$key => $value] + $this->array;
+ $this->array = [$key => $value] + $this->array; // @phpstan-ignore assign.propertyType
}
return $this;
@@ -5241,7 +5241,7 @@ public function push(...$args)
}
}
- \array_push($this->array, ...$args);
+ \array_push($this->array, ...$args); // @phpstan-ignore assign.propertyType
return $this;
}
@@ -5391,7 +5391,7 @@ public function randomMutable(?int $number = null): self
if ($number === null) {
$arrayRandValue = [$this->array[\array_rand($this->array)]];
- $this->array = $arrayRandValue;
+ $this->array = $arrayRandValue; // @phpstan-ignore assign.propertyType
return $this;
}
@@ -5535,7 +5535,7 @@ public function reduce_dimension(bool $unique = true): self
foreach ($this->getGenerator() as $val) {
if (\is_array($val)) {
- $result[] = (new static($val))->reduce_dimension($unique)->toArray();
+ $result[] = static::create($val)->reduce_dimension($unique)->toArray();
} else {
$result[] = [$val];
}
@@ -5543,7 +5543,7 @@ public function reduce_dimension(bool $unique = true): self
$result = $result === [] ? [] : \array_merge(...$result);
- $resultArrayy = new static($result);
+ $resultArrayy = static::create($result);
/**
* @psalm-suppress ImpureMethodCall - object is already re-created
@@ -7157,7 +7157,7 @@ public function unshift(...$args): self
}
}
- \array_unshift($this->array, ...$args);
+ \array_unshift($this->array, ...$args); // @phpstan-ignore assign.propertyType
return $this;
}
diff --git a/src/ArrayyIterator.php b/src/ArrayyIterator.php
index ee88e67..7b21732 100644
--- a/src/ArrayyIterator.php
+++ b/src/ArrayyIterator.php
@@ -41,7 +41,8 @@ public function current()
$value = parent::current();
if (\is_array($value)) {
- $value = \call_user_func([$this->class, 'create'], $value, static::class, false);
+ $class = $this->class;
+ $value = $class::create($value, static::class, false);
}
return $value;
@@ -62,7 +63,8 @@ public function offsetGet($offset)
$value = parent::offsetGet($offset);
if (\is_array($value)) {
- $value = \call_user_func([$this->class, 'create'], $value, static::class, false);
+ $class = $this->class;
+ $value = $class::create($value, static::class, false);
}
return $value;
diff --git a/src/ArrayyRewindableExtendedGenerator.php b/src/ArrayyRewindableExtendedGenerator.php
index ea75a65..ff195e6 100644
--- a/src/ArrayyRewindableExtendedGenerator.php
+++ b/src/ArrayyRewindableExtendedGenerator.php
@@ -41,7 +41,8 @@ public function current()
$value = $this->generator->current();
if (\is_array($value)) {
- $value = \call_user_func([$this->class, 'create'], $value, static::class, false);
+ $class = $this->class;
+ $value = $class::create($value, static::class, false);
}
return $value;
diff --git a/src/Collection/AbstractCollection.php b/src/Collection/AbstractCollection.php
index dea3b85..d99057d 100644
--- a/src/Collection/AbstractCollection.php
+++ b/src/Collection/AbstractCollection.php
@@ -63,7 +63,7 @@ abstract class AbstractCollection extends Arrayy implements CollectionInterface
*
*
* @phpstan-param array|\Arrayy\Arrayy|\Closure():array|mixed $data
- * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
*/
public function __construct(
$data = [],
@@ -263,7 +263,7 @@ public function merge(CollectionInterface ...$collections): self
* @template TKeyCreate as TKey
* @template TCreate as T
* @phpstan-param array $data
- * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
* @phpstan-return static
*
* @psalm-mutation-free
@@ -273,7 +273,7 @@ public static function create(
string $iteratorClass = ArrayyIterator::class,
bool $checkPropertiesInConstructor = true
) {
- return new static(
+ return new static( // @phpstan-ignore new.static
$data,
$iteratorClass,
$checkPropertiesInConstructor
diff --git a/src/Collection/Collection.php b/src/Collection/Collection.php
index 8998d0b..b1ffe87 100644
--- a/src/Collection/Collection.php
+++ b/src/Collection/Collection.php
@@ -98,7 +98,7 @@ class Collection extends AbstractCollection
* @param TypeInterface|null $type
*
* @phpstan-param array|array|\Arrayy\Arrayy $data
- * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
*/
public function __construct(
$data = [],
@@ -145,7 +145,7 @@ public static function construct(
): self {
$type = self::convertIntoTypeCheckArray($type);
- return new static(
+ return new static( // @phpstan-ignore new.static
$data,
ArrayyIterator::class,
$checkPropertiesInConstructorAndType,
diff --git a/src/Collection/CollectionInterface.php b/src/Collection/CollectionInterface.php
index 8a1ea34..42f1b2b 100644
--- a/src/Collection/CollectionInterface.php
+++ b/src/Collection/CollectionInterface.php
@@ -163,7 +163,7 @@ public function containsValueRecursive($value): bool;
* @template TKeyCreate as TKey
* @template TCreate as T
* @phpstan-param array $data
- * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
* @phpstan-return static
*
* @psalm-mutation-free
diff --git a/src/StaticArrayy.php b/src/StaticArrayy.php
index baf1300..5dac472 100644
--- a/src/StaticArrayy.php
+++ b/src/StaticArrayy.php
@@ -56,7 +56,7 @@ public static function __callStatic(string $name, $arguments)
$arrayy = Arrayy::create($array);
- return \call_user_func_array([$arrayy, $name], $args);
+ return $arrayy->{$name}(...$args);
}
////////////////////////////////////////////////////////////////////
diff --git a/src/Type/DetectFirstValueTypeCollection.php b/src/Type/DetectFirstValueTypeCollection.php
index 120d54f..1010247 100644
--- a/src/Type/DetectFirstValueTypeCollection.php
+++ b/src/Type/DetectFirstValueTypeCollection.php
@@ -27,7 +27,7 @@ final class DetectFirstValueTypeCollection extends Collection implements TypeInt
* @param bool $checkPropertiesInConstructor
*
* @phpstan-param array|Arrayy $data
- * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
*/
public function __construct(
$data = [],
diff --git a/src/Type/InstanceCollection.php b/src/Type/InstanceCollection.php
index 4655fe4..719f917 100644
--- a/src/Type/InstanceCollection.php
+++ b/src/Type/InstanceCollection.php
@@ -21,7 +21,7 @@ final class InstanceCollection extends Collection implements TypeInterface
* @param string|null $className
*
* @phpstan-param array $data
- * @phpstan-param class-string<\Arrayy\ArrayyIterator>|null $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator>|null $iteratorClass
* @phpstan-param class-string|null $className
*/
public function __construct(
diff --git a/src/Type/InstancesCollection.php b/src/Type/InstancesCollection.php
index 11dcb43..a1d6dde 100644
--- a/src/Type/InstancesCollection.php
+++ b/src/Type/InstancesCollection.php
@@ -21,7 +21,7 @@ final class InstancesCollection extends Collection implements TypeInterface
* @param string[]|null $classNames
*
* @phpstan-param array $data
- * @phpstan-param class-string<\Arrayy\ArrayyIterator>|null $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator>|null $iteratorClass
* @phpstan-param array>|null $classNames
*/
public function __construct(
diff --git a/src/TypeCheck/TypeCheckArray.php b/src/TypeCheck/TypeCheckArray.php
index c79b986..1746297 100644
--- a/src/TypeCheck/TypeCheckArray.php
+++ b/src/TypeCheck/TypeCheckArray.php
@@ -30,7 +30,7 @@ class TypeCheckArray extends \Arrayy\ArrayyStrict
* true, otherwise this option didn't not work anyway.
*
*
- * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
*/
public function __construct(
$data = [],
diff --git a/tests/ModelA.php b/tests/ModelA.php
index 822f0ec..0112e57 100644
--- a/tests/ModelA.php
+++ b/tests/ModelA.php
@@ -15,7 +15,7 @@ class ModelA extends \Arrayy\Arrayy implements ModelInterface
* @param array $array
* @param string $iteratorClass
*
- * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
+ * @phpstan-param class-string<\Arrayy\ArrayyIterator> $iteratorClass
*/
public function __construct($array = [], $iteratorClass = ArrayyIterator::class)
{
diff --git a/tests/StaticArrayyTest.php b/tests/StaticArrayyTest.php
index 1871fc6..a8cd2bf 100644
--- a/tests/StaticArrayyTest.php
+++ b/tests/StaticArrayyTest.php
@@ -16,34 +16,34 @@ public function testBadMethodCall()
/** @noinspection PhpUndefinedMethodInspection */
/** @noinspection PhpUnusedLocalVariableInspection */
- $result = A::invalidMethod('foo');
+ $result = A::invalidMethod('foo'); // @phpstan-ignore staticMethod.notFound
}
public function testEmptyArgsInvocation()
{
/** @noinspection PhpUndefinedMethodInspection */
- $result = A::first();
+ $result = A::first(); // @phpstan-ignore staticMethod.notFound
static::assertNull($result);
}
public function testInvocation()
{
/** @noinspection PhpUndefinedMethodInspection */
- $result = A::first(['lall', 'FOOBAR'], 1);
+ $result = A::first(['lall', 'FOOBAR'], 1); // @phpstan-ignore staticMethod.notFound
static::assertSame('lall', $result);
}
public function testPartialArgsInvocation()
{
/** @noinspection PhpUndefinedMethodInspection */
- $result = A::replaceOneValue(['foo', 'bar'], 'foo');
+ $result = A::replaceOneValue(['foo', 'bar'], 'foo'); // @phpstan-ignore staticMethod.notFound
static::assertSame(['', 'bar'], $result->getArray());
}
public function testFullArgsInvocation()
{
/** @noinspection PhpUndefinedMethodInspection */
- $result = A::replaceOneValue(['foo', 'bar'], 'foo', 'test');
+ $result = A::replaceOneValue(['foo', 'bar'], 'foo', 'test'); // @phpstan-ignore staticMethod.notFound
static::assertSame(['test', 'bar'], $result->getArray());
}