diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-25 16:21:52 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-05-11 17:01:40 +0200 |
commit | 28af364d2ae2261addc21f8830f175baa8fa72cf (patch) | |
tree | 8d30efe6ef5b82ea2bc0702aa5b8b9fa2080b82c /Zend/tests | |
parent | 4865592525e543f87deb51f5fd22022684b17f83 (diff) | |
download | php-git-28af364d2ae2261addc21f8830f175baa8fa72cf.tar.gz |
Deprecate old ReflectionParameter type declaration APIs
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.
Closes GH-5209.
Diffstat (limited to 'Zend/tests')
-rw-r--r-- | Zend/tests/bug69802_2.phpt | 3 | ||||
-rw-r--r-- | Zend/tests/type_declarations/callable_002.phpt | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/Zend/tests/bug69802_2.phpt b/Zend/tests/bug69802_2.phpt index a2de302707..dca35a665c 100644 --- a/Zend/tests/bug69802_2.phpt +++ b/Zend/tests/bug69802_2.phpt @@ -6,7 +6,8 @@ $f = (new ReflectionFunction('iterator_to_array'))->getClosure(); $r = new ReflectionMethod($f, '__invoke'); var_dump($r->getParameters()[0]->getClass()); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d object(ReflectionClass)#4 (1) { ["name"]=> string(11) "Traversable" diff --git a/Zend/tests/type_declarations/callable_002.phpt b/Zend/tests/type_declarations/callable_002.phpt index 35564ff1af..f61955c706 100644 --- a/Zend/tests/type_declarations/callable_002.phpt +++ b/Zend/tests/type_declarations/callable_002.phpt @@ -20,7 +20,12 @@ $rc = new ReflectionFunction($closure); var_dump($rc->getParameters()[0]->isCallable()); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Function ReflectionParameter::isCallable() is deprecated in %s on line %d bool(true) + +Deprecated: Function ReflectionParameter::isCallable() is deprecated in %s on line %d bool(true) + +Deprecated: Function ReflectionParameter::isCallable() is deprecated in %s on line %d bool(true) |