diff options
Diffstat (limited to 'ext/reflection/tests')
-rw-r--r-- | ext/reflection/tests/ReflectionMethod_basic2.phpt | 8 | ||||
-rw-r--r-- | ext/reflection/tests/bug42976.phpt | 4 | ||||
-rw-r--r-- | ext/reflection/tests/bug51905.phpt | 28 | ||||
-rw-r--r-- | ext/reflection/tests/bug51911.phpt | 22 | ||||
-rw-r--r-- | ext/reflection/tests/bug52057.phpt | 54 |
5 files changed, 110 insertions, 6 deletions
diff --git a/ext/reflection/tests/ReflectionMethod_basic2.phpt b/ext/reflection/tests/ReflectionMethod_basic2.phpt index e2c23c1c1..c91af6770 100644 --- a/ext/reflection/tests/ReflectionMethod_basic2.phpt +++ b/ext/reflection/tests/ReflectionMethod_basic2.phpt @@ -153,8 +153,8 @@ __toString(): string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] { - Parameters [2] { - Parameter #0 [ <optional> $class ] - Parameter #1 [ <optional> $name ] + Parameter #0 [ <required> $class ] + Parameter #1 [ <required> $name ] } } " @@ -163,8 +163,8 @@ export(): string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] { - Parameters [2] { - Parameter #0 [ <optional> $class ] - Parameter #1 [ <optional> $name ] + Parameter #0 [ <required> $class ] + Parameter #1 [ <required> $name ] } } " diff --git a/ext/reflection/tests/bug42976.phpt b/ext/reflection/tests/bug42976.phpt index 3669d957d..2e4ade284 100644 --- a/ext/reflection/tests/bug42976.phpt +++ b/ext/reflection/tests/bug42976.phpt @@ -28,11 +28,11 @@ string(9) "x.changed" Warning: Parameter 1 to C::__construct() expected to be a reference, value given in %sbug42976.php on line 15 -Warning: Invocation of C's constructor failed in %sbug42976.php on line 15 +Warning: ReflectionClass::newInstance(): Invocation of C's constructor failed in %sbug42976.php on line 15 string(10) "x.original" Warning: Parameter 1 to C::__construct() expected to be a reference, value given in %sbug42976.php on line 18 -Warning: Invocation of C's constructor failed in %sbug42976.php on line 18 +Warning: ReflectionClass::newInstanceArgs(): Invocation of C's constructor failed in %sbug42976.php on line 18 string(10) "x.original" Done diff --git a/ext/reflection/tests/bug51905.phpt b/ext/reflection/tests/bug51905.phpt new file mode 100644 index 000000000..8969924e4 --- /dev/null +++ b/ext/reflection/tests/bug51905.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #51905 (ReflectionParameter fails if default value is an array with an access to self::) +--FILE-- +<?php + +class Bar { + const Y = 20; +} + +class Foo extends Bar { + const X = 12; + public function x($x = 1, $y = array(self::X), $z = parent::Y) {} +} + +$clazz = new ReflectionClass('Foo'); +$method = $clazz->getMethod('x'); +foreach ($method->getParameters() as $param) { + if ( $param->isDefaultValueAvailable()) + echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n"; +} + +?> +--EXPECT-- +$x : 1 +$y : array ( + 0 => 12, +) +$z : 20 diff --git a/ext/reflection/tests/bug51911.phpt b/ext/reflection/tests/bug51911.phpt new file mode 100644 index 000000000..12eb459fb --- /dev/null +++ b/ext/reflection/tests/bug51911.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with constant array) +--FILE-- +<?php + +class Foo { + const X = 1; + public function x($x = array(1)) {} +} + +$clazz = new ReflectionClass('Foo'); +$method = $clazz->getMethod('x'); +foreach ($method->getParameters() as $param) { + if ( $param->isDefaultValueAvailable()) + echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n"; +} + +?> +--EXPECT-- +$x : array ( + 0 => 1, +) diff --git a/ext/reflection/tests/bug52057.phpt b/ext/reflection/tests/bug52057.phpt new file mode 100644 index 000000000..b80703571 --- /dev/null +++ b/ext/reflection/tests/bug52057.phpt @@ -0,0 +1,54 @@ +--TEST-- +Bug #52057 (ReflectionClass fails on Closure class) +--FILE-- +<?php + +$closure = function($a) { echo $a; }; + +$reflection = new ReflectionClass('closure'); +var_dump($reflection->hasMethod('__invoke')); // true + +$reflection = new ReflectionClass($closure); +var_dump($reflection->hasMethod('__invoke')); // true + +$reflection = new ReflectionObject($closure); +var_dump($reflection->hasMethod('__invoke')); // true + +$reflection = new ReflectionClass('closure'); +var_dump($h = $reflection->getMethod('__invoke')); // true +var_dump($h->class.'::'.$h->getName()); + +$reflection = new ReflectionClass($closure); +var_dump($h = $reflection->getMethod('__invoke')); // true +var_dump($h->class.'::'.$h->getName()); + +$reflection = new ReflectionObject($closure); +var_dump($h = $reflection->getMethod('__invoke')); // true +var_dump($h->class.'::'.$h->getName()); + +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) +object(ReflectionMethod)#%d (2) { + ["name"]=> + string(8) "__invoke" + ["class"]=> + string(7) "Closure" +} +string(17) "Closure::__invoke" +object(ReflectionMethod)#%d (2) { + ["name"]=> + string(8) "__invoke" + ["class"]=> + string(7) "Closure" +} +string(17) "Closure::__invoke" +object(ReflectionMethod)#%d (2) { + ["name"]=> + string(8) "__invoke" + ["class"]=> + string(7) "Closure" +} +string(17) "Closure::__invoke" |