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

Deprecate old ReflectionParameter type declaration APIs #5209

Closed
wants to merge 1 commit into from

Conversation

nikic
Copy link
Member

@nikic nikic commented Feb 25, 2020

This deprecates:

  • 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.

@nikic nikic added the Feature label Feb 25, 2020
@nikic nikic force-pushed the deprecate-old-reflection-type branch from 83fd83c to 06f64ef Compare February 25, 2020 15:46
@php-pulls php-pulls closed this in 28af364 May 11, 2020
khs1994 added a commit to pcit-ce/pcit that referenced this pull request May 19, 2020
Signed-off-by: Kang Huaishuai <khs1994@khs1994.com>
khs1994 added a commit to pcit-ce/pcit that referenced this pull request May 19, 2020
Signed-off-by: Kang Huaishuai <khs1994@khs1994.com>
@carusogabriel carusogabriel added this to the PHP 8.0 milestone May 29, 2020
ciaranmcnulty added a commit to ciaranmcnulty/Behat that referenced this pull request Jun 25, 2020
This is deprecated in PHP 8 (php/php-src#5209). Because we require PHP >=7.1 we can rely on getType returning a ReflectionNamedType
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants