Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function ReflectionParameter::isArray() is deprecated #475

Closed
blackcoder87 opened this issue May 14, 2020 · 3 comments · Fixed by #529
Closed

Function ReflectionParameter::isArray() is deprecated #475

blackcoder87 opened this issue May 14, 2020 · 3 comments · Fixed by #529
Labels
Priority: Medium Status: Pending Type: Bug The issue documents broken, incorrect, or confusing behavior.

Comments

@blackcoder87
Copy link
Member

Unit tests are failing with the message "Function ReflectionParameter::isArray() is deprecated" in Travis and PHP nightly (PHP 8.0.0-dev (cli) (built: May 13 2020 04:31:32) ( ZTS )).

ReflectionParameter::isArray()
ReflectionParameter::isCallable()
ReflectionParameter::getClass()

These APIs have been superseded by ReflectionParameter::getType() since PHP 7.0. Types introduced since that time are not available through the old APIs, and their behavior is getting increasingly confusing. This is how they interact with PHP 8 union types:

isArray() will return true if the type is array or ?array, but not any other union type
Same for isCallable().
getClass() will return a class for T|int etc, as long as the union only contains a single type. T1|T2 will return null.
This behavior is not particularly reasonable or useful, and will get more confusing as new type system extensions are added.

#446

@blackcoder87 blackcoder87 added Type: Bug The issue documents broken, incorrect, or confusing behavior. Priority: Medium labels May 14, 2020
blackcoder87 added a commit that referenced this issue May 14, 2020
@blackcoder87 blackcoder87 self-assigned this Jun 3, 2020
@blackcoder87
Copy link
Member Author

Looks like this is triggered by the old version of PHPUnit or to be more precise "phpunit/phpunit-mock-objects".
We currently (as of today!) use version 6.5.14.

PHPUnit 7.5.20 requires PHP 7.1 or newer.
PHPUnit 8.5.8 requires PHP 7.2 or newer.
PHPUnit 9.2.5 requires PHP 7.3 or newer.

PHP 8 is scheduled for Nov 26 2020.
https://wiki.php.net/todo/php80#timetable

This package is abandoned and no longer maintained. No replacement package was suggested.

https://github.com/sebastianbergmann/dbunit
https://packagist.org/packages/phpunit/dbunit
sebastianbergmann/dbunit#217

https://github.com/sebastianbergmann/phpunit-mock-objects
https://packagist.org/packages/phpunit/phpunit-mock-objects

@blackcoder87
Copy link
Member Author

With PHPUnit 7.5.20 on PHP 8

Method ReflectionParameter::getClass() is deprecated

@blackcoder87 blackcoder87 removed their assignment Jun 28, 2020
@sminnee
Copy link

sminnee commented Aug 30, 2020

FYI I've pushed a fork of phpunit-mock-objects for this reason https://github.com/sminnee/phpunit-mock-objects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium Status: Pending Type: Bug The issue documents broken, incorrect, or confusing behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants