File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Using invalid self/parent types in closure
3
+ --FILE--
4
+ <?php
5
+
6
+ $ fn1 = function (self $ x ) {};
7
+ try {
8
+ (new ReflectionFunction ($ fn1 ))->getParameters ()[0 ]->getClass ();
9
+ } catch (ReflectionException $ e ) {
10
+ echo $ e ->getMessage (), "\n" ;
11
+ }
12
+
13
+ $ fn2 = function (parent $ x ) {};
14
+ try {
15
+ (new ReflectionFunction ($ fn2 ))->getParameters ()[0 ]->getClass ();
16
+ } catch (ReflectionException $ e ) {
17
+ echo $ e ->getMessage (), "\n" ;
18
+ }
19
+
20
+ class Test {}
21
+ $ fn3 = (function (parent $ x ) {})->bindTo (new Test , Test::class);
22
+ try {
23
+ (new ReflectionFunction ($ fn3 ))->getParameters ()[0 ]->getClass ();
24
+ } catch (ReflectionException $ e ) {
25
+ echo $ e ->getMessage (), "\n" ;
26
+ }
27
+
28
+ ?>
29
+ --EXPECTF--
30
+ Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
31
+ Parameter uses "self" as type but function is not a class member
32
+
33
+ Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
34
+ Parameter uses "parent" as type but function is not a class member
35
+
36
+ Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
37
+ Parameter uses "parent" as type although class does not have a parent
You can’t perform that action at this time.
0 commit comments