You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Array reduce not understanding callback return with generics #8071
@@ @@
18: Method Inheritance::inherit() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<string>.
-PHP 7.1 – 7.4 (2 errors)+PHP 7.1 – 7.4 (9 errors)
==========
18: Method Inheritance::inherit() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<string>.
-33: Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.+33: Method Inheritance::callBack() has parameter $carry with no value type specified in iterable type array.+33: Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.+33: PHPDoc tag @param for parameter $carry with type array<TKey of (int|string), TValues of bool|float|int|string|null>|null is not subtype of native type array|null.+33: Parameter $carry of method Inheritance::callBack() has invalid type null.+35: Strict comparison using === between array|null and null will always evaluate to false.+39: Argument of an invalid type array|null supplied for foreach, only iterables are supported.+44: Cannot access offset (int|string) on array|null.+47: Method Inheritance::callBack() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array|null.
Full report
PHP 8.0 – 8.2 (1 error)
Line
Error
18
`Method Inheritance::inherit() should return array<TKey of (int
PHP 7.1 – 7.4 (9 errors)
Line
Error
18
`Method Inheritance::inherit() should return array<TKey of (int
33
Method Inheritance::callBack() has parameter $carry with no value type specified in iterable type array.
33
Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.
33
`PHPDoc tag @PARAM for parameter $carry with type array<TKey of (int
33
Parameter $carry of method Inheritance::callBack() has invalid type null.
35
`Strict comparison using === between array
39
`Argument of an invalid type array
44
`Cannot access offset (int
47
`Method Inheritance::callBack() should return array<TKey of (int
@@ @@-PHP 8.0 – 8.2 (1 error)+PHP 8.0 – 8.2 (2 errors)
==========
18: Method Inheritance::inherit() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<string>.
+33: Static method Inheritance::callBack() is unused.-PHP 7.1 – 7.4 (2 errors)+PHP 7.1 – 7.4 (10 errors)
==========
18: Method Inheritance::inherit() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<string>.
-33: Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.+33: Method Inheritance::callBack() has parameter $carry with no value type specified in iterable type array.+33: Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.+33: PHPDoc tag @param for parameter $carry with type array<TKey of (int|string), TValues of bool|float|int|string|null>|null is not subtype of native type array|null.+33: Parameter $carry of method Inheritance::callBack() has invalid type null.+33: Static method Inheritance::callBack() is unused.+35: Strict comparison using === between array|null and null will always evaluate to false.+39: Argument of an invalid type array|null supplied for foreach, only iterables are supported.+44: Cannot access offset (int|string) on array|null.+47: Method Inheritance::callBack() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array|null.
Full report
PHP 8.0 – 8.2 (2 errors)
Line
Error
18
`Method Inheritance::inherit() should return array<TKey of (int
33
Static method Inheritance::callBack() is unused.
PHP 7.1 – 7.4 (10 errors)
Line
Error
18
`Method Inheritance::inherit() should return array<TKey of (int
33
Method Inheritance::callBack() has parameter $carry with no value type specified in iterable type array.
33
Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.
33
`PHPDoc tag @PARAM for parameter $carry with type array<TKey of (int
33
Parameter $carry of method Inheritance::callBack() has invalid type null.
33
Static method Inheritance::callBack() is unused.
35
`Strict comparison using === between array
39
`Argument of an invalid type array
44
`Cannot access offset (int
47
`Method Inheritance::callBack() should return array<TKey of (int
@@ @@
18: Method Inheritance::inherit() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<string>.
-PHP 7.1 – 7.4 (2 errors)+PHP 7.1 – 7.4 (8 errors)
==========
18: Method Inheritance::inherit() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<string>.
-33: Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.+33: Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.+33: PHPDoc tag @param for parameter $carry with type array<TKey of (int|string), TValues of bool|float|int|string|null>|null is not subtype of native type array|null.+33: Parameter $carry of method Inheritance::callBack() has invalid type null.+35: Strict comparison using === between array<TKey of (int|string), TValues of bool|float|int|string|null>|null and null will always evaluate to false.+39: Argument of an invalid type array<TKey of (int|string), TValues of bool|float|int|string|null>|null supplied for foreach, only iterables are supported.+44: Cannot access offset TKey of (int|string) on array<TKey of (int|string), TValues of bool|float|int|string|null>|null.+47: Method Inheritance::callBack() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<TKey of (int|string), TValues of bool|float|int|string|null>|null.
Full report
PHP 8.0 – 8.2 (1 error)
Line
Error
18
`Method Inheritance::inherit() should return array<TKey of (int
PHP 7.1 – 7.4 (8 errors)
Line
Error
18
`Method Inheritance::inherit() should return array<TKey of (int
33
Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.
33
`PHPDoc tag @PARAM for parameter $carry with type array<TKey of (int
33
Parameter $carry of method Inheritance::callBack() has invalid type null.
35
`Strict comparison using === between array<TKey of (int
39
`Argument of an invalid type array<TKey of (int
44
`Cannot access offset TKey of (int
47
`Method Inheritance::callBack() should return array<TKey of (int
@@ @@
18: Method Inheritance::inherit() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<string>.
-PHP 7.1 – 7.4 (2 errors)+PHP 7.1 – 7.4 (8 errors)
==========
18: Method Inheritance::inherit() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<string>.
-33: Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.+33: Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.+33: PHPDoc tag @param for parameter $carry with type array<TKey of (int|string), TValues of bool|float|int|string|null>|null is not subtype of native type array|null.+33: Parameter $carry of method Inheritance::callBack() has invalid type null.+35: Strict comparison using === between array<TKey of (int|string), TValues of bool|float|int|string|null>|null and null will always evaluate to false.+39: Argument of an invalid type array<TKey of (int|string), TValues of bool|float|int|string|null>|null supplied for foreach, only iterables are supported.+44: Cannot access offset TKey of (int|string) on array<TKey of (int|string), TValues of bool|float|int|string|null>|(iterable&null).+47: Method Inheritance::callBack() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<TKey of (int|string), TValues of bool|float|int|string|null>|null.
Full report
PHP 8.0 – 8.2 (1 error)
Line
Error
18
`Method Inheritance::inherit() should return array<TKey of (int
PHP 7.1 – 7.4 (8 errors)
Line
Error
18
`Method Inheritance::inherit() should return array<TKey of (int
33
Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.
33
`PHPDoc tag @PARAM for parameter $carry with type array<TKey of (int
33
Parameter $carry of method Inheritance::callBack() has invalid type null.
35
`Strict comparison using === between array<TKey of (int
39
`Argument of an invalid type array<TKey of (int
44
`Cannot access offset TKey of (int
47
`Method Inheritance::callBack() should return array<TKey of (int
@@ @@-PHP 8.0 – 8.2 (1 error)+PHP 8.0 – 8.2 (2 errors)
==========
+15: Return type array<TKey of (int|string), TValues of bool|float|int|string|null> of method Inheritance::inherit() can be narrowed to array<TKey of (int|string), string>.
18: Method Inheritance::inherit() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<string>.
-PHP 7.1 – 7.4 (2 errors)+PHP 7.1 – 7.4 (9 errors)
==========
+15: Return type array<TKey of (int|string), TValues of bool|float|int|string|null> of method Inheritance::inherit() can be narrowed to array<TKey of (int|string), string>.
18: Method Inheritance::inherit() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<string>.
-33: Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.+33: Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.+33: PHPDoc tag @param for parameter $carry with type array<TKey of (int|string), TValues of bool|float|int|string|null>|null is not subtype of native type array|null.+33: Parameter $carry of method Inheritance::callBack() has invalid type null.+35: Strict comparison using === between array<TKey of (int|string), TValues of bool|float|int|string|null>|null and null will always evaluate to false.+39: Argument of an invalid type array<TKey of (int|string), TValues of bool|float|int|string|null>|null supplied for foreach, only iterables are supported.+44: Cannot access offset TKey of (int|string) on array<TKey of (int|string), TValues of bool|float|int|string|null>|null.+47: Method Inheritance::callBack() should return array<TKey of (int|string), TValues of bool|float|int|string|null> but returns array<TKey of (int|string), TValues of bool|float|int|string|null>|null.
Full report
PHP 8.0 – 8.2 (2 errors)
Line
Error
15
`Return type array<TKey of (int
18
`Method Inheritance::inherit() should return array<TKey of (int
PHP 7.1 – 7.4 (9 errors)
Line
Error
15
`Return type array<TKey of (int
18
`Method Inheritance::inherit() should return array<TKey of (int
33
Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.
33
`PHPDoc tag @PARAM for parameter $carry with type array<TKey of (int
33
Parameter $carry of method Inheritance::callBack() has invalid type null.
35
`Strict comparison using === between array<TKey of (int
39
`Argument of an invalid type array<TKey of (int
44
`Cannot access offset TKey of (int
47
`Method Inheritance::callBack() should return array<TKey of (int
Activity
phpstan-bot commentedon Oct 5, 2022
@BackEndTea After the latest push in 1.9.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.2
No errors
PHP 7.1 – 7.4 (1 error)
Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.github-actions commentedon Nov 6, 2022
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
ondrejmirtes commentedon Jan 27, 2023
This issue was never fixed, but merely silenced...
phpstan-bot commentedon Sep 4, 2024
@BackEndTea After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.2 (1 error)
PHP 7.1 – 7.4 (9 errors)
Method Inheritance::callBack() has parameter $carry with no value type specified in iterable type array.Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.Parameter $carry of method Inheritance::callBack() has invalid type null.phpstan-bot commentedon Jan 4, 2025
@BackEndTea After the latest push in 2.1.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.2 (2 errors)
Static method Inheritance::callBack() is unused.PHP 7.1 – 7.4 (10 errors)
Method Inheritance::callBack() has parameter $carry with no value type specified in iterable type array.Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.Parameter $carry of method Inheritance::callBack() has invalid type null.Static method Inheritance::callBack() is unused.phpstan-bot commentedon Apr 29, 2025
@BackEndTea After the latest push in 2.1.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.2 (1 error)
PHP 7.1 – 7.4 (8 errors)
Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.Parameter $carry of method Inheritance::callBack() has invalid type null.phpstan-bot commentedon Aug 4, 2025
@BackEndTea After the latest push in 2.1.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.2 (1 error)
PHP 7.1 – 7.4 (8 errors)
Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.Parameter $carry of method Inheritance::callBack() has invalid type null.phpstan-bot commentedon Sep 22, 2025
@BackEndTea After the latest push in 2.1.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.2 (2 errors)
PHP 7.1 – 7.4 (9 errors)
Method Inheritance::callBack() uses native union types but they're supported only on PHP 8.0 and later.Parameter $carry of method Inheritance::callBack() has invalid type null.