diff options
Diffstat (limited to 'ext/reflection/tests')
85 files changed, 669 insertions, 902 deletions
diff --git a/ext/reflection/tests/009.phpt b/ext/reflection/tests/009.phpt index 09df90c8c3..d582623cbd 100644 --- a/ext/reflection/tests/009.phpt +++ b/ext/reflection/tests/009.phpt @@ -14,7 +14,7 @@ function test ($a, $b = 1, $c = "") { $func = new ReflectionFunction("test"); -var_dump($func->export("test")); +echo $func; echo "--getName--\n"; var_dump($func->getName()); echo "--isInternal--\n"; @@ -60,8 +60,6 @@ Function [ <user> function test ] { Parameter #2 [ <optional> $c = '' ] } } - -NULL --getName-- string(4) "test" --isInternal-- diff --git a/ext/reflection/tests/025.phpt b/ext/reflection/tests/025.phpt index f1e13d9240..c18a0f5b8e 100644 --- a/ext/reflection/tests/025.phpt +++ b/ext/reflection/tests/025.phpt @@ -14,7 +14,7 @@ function test ($a, $b = 1, $c = "") { $func = new ReflectionFunction("test"); -var_dump($func->export("test")); +echo $func; echo "--getName--\n"; var_dump($func->getName()); echo "--isInternal--\n"; @@ -60,8 +60,6 @@ Function [ <user> function test ] { Parameter #2 [ <optional> $c = '' ] } } - -NULL --getName-- string(4) "test" --isInternal-- diff --git a/ext/reflection/tests/ReflectionClassConstant_basic1.phpt b/ext/reflection/tests/ReflectionClassConstant_basic1.phpt index 548d64e1bf..181360d733 100644 --- a/ext/reflection/tests/ReflectionClassConstant_basic1.phpt +++ b/ext/reflection/tests/ReflectionClassConstant_basic1.phpt @@ -56,9 +56,13 @@ __toString(): string(35) "Constant [ public bool PUB ] { 1 } " export(): + +Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d string(35) "Constant [ public bool PUB ] { 1 } " export(): + +Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d Constant [ public bool PUB ] { 1 } NULL @@ -73,7 +77,7 @@ bool(false) isProtected(): bool(false) getModifiers(): -int(256) +int(1) getDeclaringClass(): object(ReflectionClass)#3 (1) { ["name"]=> @@ -90,9 +94,13 @@ __toString(): string(38) "Constant [ protected int PROT ] { 4 } " export(): + +Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d string(38) "Constant [ protected int PROT ] { 4 } " export(): + +Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d Constant [ protected int PROT ] { 4 } NULL @@ -107,7 +115,7 @@ bool(false) isProtected(): bool(true) getModifiers(): -int(512) +int(2) getDeclaringClass(): object(ReflectionClass)#3 (1) { ["name"]=> @@ -124,9 +132,13 @@ __toString(): string(45) "Constant [ private string PRIV ] { keepOut } " export(): + +Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d string(45) "Constant [ private string PRIV ] { keepOut } " export(): + +Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d Constant [ private string PRIV ] { keepOut } NULL @@ -141,7 +153,7 @@ bool(true) isProtected(): bool(false) getModifiers(): -int(1024) +int(4) getDeclaringClass(): object(ReflectionClass)#3 (1) { ["name"]=> @@ -158,9 +170,13 @@ __toString(): string(45) "Constant [ private string PRIV ] { keepOut } " export(): + +Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d string(45) "Constant [ private string PRIV ] { keepOut } " export(): + +Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d Constant [ private string PRIV ] { keepOut } NULL @@ -175,7 +191,7 @@ bool(true) isProtected(): bool(false) getModifiers(): -int(1024) +int(4) getDeclaringClass(): object(ReflectionClass)#3 (1) { ["name"]=> diff --git a/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt b/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt deleted file mode 100644 index a4e5f95564..0000000000 --- a/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -ReflectionClass::getFileName(), ReflectionClass::getStartLine(), ReflectionClass::getEndLine() - bad params ---FILE-- -<?php -Class C { } - -$rc = new ReflectionClass("C"); -$methods = array("getFileName", "getStartLine", "getEndLine"); - -foreach ($methods as $method) { - var_dump($rc->$method()); - var_dump($rc->$method(null)); - var_dump($rc->$method('X', 0)); -} -?> ---EXPECTF-- -string(%d) "%s" - -Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 2 given in %s on line %d -NULL -int(2) - -Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 2 given in %s on line %d -NULL -int(2) - -Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 2 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt b/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt index 30694bf536..80d2be2585 100644 --- a/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt +++ b/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt @@ -1,12 +1,12 @@ --TEST-- -ReflectionClass::export() - array constants +ReflectionClass::__toString() - array constants --FILE-- <?php Class A { const A = 8; const B = ["a", "b"]; } -ReflectionClass::export("A"); +echo new ReflectionClass("A"), "\n"; ?> --EXPECTF-- Class [ <user> class A ] { diff --git a/ext/reflection/tests/ReflectionClass_export_basic1.phpt b/ext/reflection/tests/ReflectionClass_export_basic1.phpt index abfa41f3d7..d9183442c4 100644 --- a/ext/reflection/tests/ReflectionClass_export_basic1.phpt +++ b/ext/reflection/tests/ReflectionClass_export_basic1.phpt @@ -1,5 +1,5 @@ --TEST-- -ReflectionClass::export() - various parameters +ReflectionClass::__toString() - various parameters --FILE-- <?php Class A { @@ -17,7 +17,7 @@ Class A { Class C extends A { } define('K', "16 chars long --"); -ReflectionClass::export("C"); +echo new ReflectionClass("C"), "\n"; ?> --EXPECTF-- Class [ <user> class C extends A ] { diff --git a/ext/reflection/tests/ReflectionClass_export_basic2.phpt b/ext/reflection/tests/ReflectionClass_export_basic2.phpt index 5699529b3d..12cee4e6e3 100644 --- a/ext/reflection/tests/ReflectionClass_export_basic2.phpt +++ b/ext/reflection/tests/ReflectionClass_export_basic2.phpt @@ -1,5 +1,5 @@ --TEST-- -ReflectionClass::export() - ensure inherited private props are hidden. +ReflectionClass::__toString() - ensure inherited private props are hidden. --FILE-- <?php Class c { @@ -9,8 +9,8 @@ Class c { class d extends c {} -ReflectionClass::export("c"); -ReflectionClass::export("d"); +echo new ReflectionClass("c"), "\n"; +echo new ReflectionClass("d"), "\n"; ?> --EXPECTF-- Class [ <user> class c ] { diff --git a/ext/reflection/tests/ReflectionClass_getConstants_error.phpt b/ext/reflection/tests/ReflectionClass_getConstants_error.phpt deleted file mode 100644 index 1784d712a4..0000000000 --- a/ext/reflection/tests/ReflectionClass_getConstants_error.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -ReflectionClass::getConstants() ---FILE-- -<?php -class X { -} - -$rc = new reflectionClass('X'); - -//Test invalid arguments -$rc->getConstants('X'); -$rc->getConstants(true); -$rc->getConstants(null); -$rc->getConstants('A', 'B'); - -?> ---EXPECTF-- -Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d - -Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d - -Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d - -Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 2 given in %s on line %d diff --git a/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt b/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt deleted file mode 100644 index 7e8932a5ed..0000000000 --- a/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -ReflectionClass::getConstructor() - bad params ---FILE-- -<?php -class C {} -$rc = new ReflectionClass('C'); -var_dump($rc->getConstructor(null)); -var_dump($rc->getConstructor('X')); -var_dump($rc->getConstructor(true)); -var_dump($rc->getConstructor(array(1,2,3))); -?> ---EXPECTF-- -Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionClass_getDefaultProperties_002.phpt b/ext/reflection/tests/ReflectionClass_getDefaultProperties_002.phpt deleted file mode 100644 index 7c178ac8ea..0000000000 --- a/ext/reflection/tests/ReflectionClass_getDefaultProperties_002.phpt +++ /dev/null @@ -1,44 +0,0 @@ ---TEST-- -ReflectionClass::getDefaultProperties(), ReflectionClass::getStaticProperties() - wrong param count ---CREDITS-- -Robin Fernandes <robinf@php.net> -Steve Seear <stevseea@php.net> ---FILE-- -<?php -interface I {} -class C implements I {} -$rc = new ReflectionClass('C'); -var_dump($rc->getDefaultProperties(null)); -var_dump($rc->getDefaultProperties('X')); -var_dump($rc->getDefaultProperties(true)); -var_dump($rc->getDefaultProperties(array(1,2,3))); -var_dump($rc->getStaticProperties(null)); -var_dump($rc->getStaticProperties('X')); -var_dump($rc->getStaticProperties(true)); -var_dump($rc->getStaticProperties(array(1,2,3))); - -?> ---EXPECTF-- -Warning: ReflectionClass::getDefaultProperties() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getDefaultProperties() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getDefaultProperties() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getDefaultProperties() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getStaticProperties() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getStaticProperties() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getStaticProperties() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getStaticProperties() expects exactly 0 parameters, 1 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionClass_getDocComment_002.phpt b/ext/reflection/tests/ReflectionClass_getDocComment_002.phpt deleted file mode 100644 index 5bbd596488..0000000000 --- a/ext/reflection/tests/ReflectionClass_getDocComment_002.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -ReflectionClass::getDocComment() - bad params ---CREDITS-- -Robin Fernandes <robinf@php.net> -Steve Seear <stevseea@php.net> ---FILE-- -<?php -class C {} -$rc = new ReflectionClass('C'); -var_dump($rc->getDocComment(null)); -var_dump($rc->getDocComment('X')); -var_dump($rc->getDocComment(true)); -var_dump($rc->getDocComment(array(1,2,3))); -?> ---EXPECTF-- -Warning: ReflectionClass::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt index d99cd2561c..998bd4bea6 100644 --- a/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt +++ b/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt @@ -25,24 +25,24 @@ Array [name] => I6 ) - [I2] => ReflectionClass Object + [I4] => ReflectionClass Object ( - [name] => I2 + [name] => I4 ) - [I1] => ReflectionClass Object + [I3] => ReflectionClass Object ( - [name] => I1 + [name] => I3 ) - [I4] => ReflectionClass Object + [I2] => ReflectionClass Object ( - [name] => I4 + [name] => I2 ) - [I3] => ReflectionClass Object + [I1] => ReflectionClass Object ( - [name] => I3 + [name] => I1 ) [I5] => ReflectionClass Object diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_004.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_004.phpt deleted file mode 100644 index f62d58cd72..0000000000 --- a/ext/reflection/tests/ReflectionClass_getInterfaces_004.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -ReflectionClass::getInterfaces() - wrong param count ---CREDITS-- -Robin Fernandes <robinf@php.net> -Steve Seear <stevseea@php.net> ---FILE-- -<?php -interface I {} -class C implements I {} -$rc = new ReflectionClass('C'); -var_dump($rc->getInterfaces(null)); -var_dump($rc->getInterfaces('X')); -var_dump($rc->getInterfaces(true)); -var_dump($rc->getInterfaces(array(1,2,3))); -?> ---EXPECTF-- -Warning: ReflectionClass::getInterfaces() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getInterfaces() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getInterfaces() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getInterfaces() expects exactly 0 parameters, 1 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionClass_getMethods_002.phpt b/ext/reflection/tests/ReflectionClass_getMethods_002.phpt deleted file mode 100644 index b6a78aa318..0000000000 --- a/ext/reflection/tests/ReflectionClass_getMethods_002.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -ReflectionClass::getMethods() - invalid arguments ---CREDITS-- -Robin Fernandes <robinf@php.net> -Steve Seear <stevseea@php.net> ---FILE-- -<?php -$rc = new ReflectionClass("ReflectionClass"); -echo "\nTest invalid arguments:"; -$rc->getMethods('X'); -$rc->getMethods('X', true); - -?> ---EXPECTF-- -Test invalid arguments: -Warning: ReflectionClass::getMethods() expects parameter 1 to be int, string given in %s on line 4 - -Warning: ReflectionClass::getMethods() expects at most 1 parameter, 2 given in %s on line 5 diff --git a/ext/reflection/tests/ReflectionClass_getMethods_003.phpt b/ext/reflection/tests/ReflectionClass_getMethods_003.phpt index 885bd908f1..b08fcaa4d4 100644 --- a/ext/reflection/tests/ReflectionClass_getMethods_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getMethods_003.phpt @@ -17,9 +17,9 @@ class C { } $rc = new ReflectionClass("C"); -$StaticFlag = 0x01; -$pubFlag = 0x100; -$privFlag = 0x400; +$StaticFlag = ReflectionMethod::IS_STATIC; +$pubFlag = ReflectionMethod::IS_PUBLIC; +$privFlag = ReflectionMethod::IS_PRIVATE; echo "No methods:"; var_dump($rc->getMethods(0)); diff --git a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt index f77bbacda7..ffe8876133 100644 --- a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt @@ -29,8 +29,8 @@ dump_modifiers('g'); ?> --EXPECT-- int(0) +int(64) int(32) -int(4) int(0) int(0) int(0) diff --git a/ext/reflection/tests/ReflectionClass_getName_error.phpt b/ext/reflection/tests/ReflectionClass_getName_error.phpt deleted file mode 100644 index 145704e7bc..0000000000 --- a/ext/reflection/tests/ReflectionClass_getName_error.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -ReflectionClass::getName() - invalid params ---FILE-- -<?php - -$r1 = new ReflectionClass("stdClass"); - -var_dump($r1->getName('X')); -var_dump($r1->getName('X', true)); -?> ---EXPECTF-- -Warning: ReflectionClass::getName() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getName() expects exactly 0 parameters, 2 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionClass_getProperties_002.phpt b/ext/reflection/tests/ReflectionClass_getProperties_002.phpt deleted file mode 100644 index 1f7dc24d74..0000000000 --- a/ext/reflection/tests/ReflectionClass_getProperties_002.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -ReflectionClass::getProperties() - invalid arguments ---CREDITS-- -Robin Fernandes <robinf@php.net> -Steve Seear <stevseea@php.net> ---FILE-- -<?php -$rc = new ReflectionClass("ReflectionClass"); -echo "\nTest invalid arguments:"; -$rc->getProperties('X'); -$rc->getProperties('X', true); -?> ---EXPECTF-- -Test invalid arguments: -Warning: ReflectionClass::getProperties() expects parameter 1 to be int, string given in %s on line 4 - -Warning: ReflectionClass::getProperties() expects at most 1 parameter, 2 given in %s on line 5 diff --git a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt index d4a00f05fe..fe3792a30f 100644 --- a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt @@ -17,9 +17,9 @@ class C { } $rc = new ReflectionClass("C"); -$StaticFlag = 0x01; -$pubFlag = 0x100; -$privFlag = 0x400; +$StaticFlag = ReflectionProperty::IS_STATIC; +$pubFlag = ReflectionProperty::IS_PUBLIC; +$privFlag = ReflectionProperty::IS_PRIVATE; echo "No properties:"; var_dump($rc->getProperties(0)); diff --git a/ext/reflection/tests/ReflectionClass_isInstance_error.phpt b/ext/reflection/tests/ReflectionClass_isInstance_error.phpt deleted file mode 100644 index f4c553dec6..0000000000 --- a/ext/reflection/tests/ReflectionClass_isInstance_error.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -ReflectionClass::isInstance() - invalid params ---FILE-- -<?php -class X {} - -$rc = new ReflectionClass("X"); -$instance = new X; - -var_dump($rc->isInstance()); -var_dump($rc->isInstance($instance, $instance)); -var_dump($rc->isInstance(1)); -var_dump($rc->isInstance(1.5)); -var_dump($rc->isInstance(true)); -var_dump($rc->isInstance('X')); -var_dump($rc->isInstance(null)); - -?> ---EXPECTF-- -Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 0 given in %s on line 7 -NULL - -Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 2 given in %s on line 8 -NULL - -Warning: ReflectionClass::isInstance() expects parameter 1 to be object, %s given in %s on line 9 -NULL - -Warning: ReflectionClass::isInstance() expects parameter 1 to be object, float given in %s on line 10 -NULL - -Warning: ReflectionClass::isInstance() expects parameter 1 to be object, bool given in %s on line 11 -NULL - -Warning: ReflectionClass::isInstance() expects parameter 1 to be object, string given in %s on line 12 -NULL - -Warning: ReflectionClass::isInstance() expects parameter 1 to be object, null given in %s on line 13 -NULL diff --git a/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt b/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt deleted file mode 100644 index 5263643023..0000000000 --- a/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -ReflectionClass::IsInstantiable() ---FILE-- -<?php -class privateCtorOld { - private function privateCtorOld() {} -} -$reflectionClass = new ReflectionClass("privateCtorOld"); - -var_dump($reflectionClass->IsInstantiable('X')); -var_dump($reflectionClass->IsInstantiable(0, null)); - -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d - -Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 2 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionClass_isInternal_error.phpt b/ext/reflection/tests/ReflectionClass_isInternal_error.phpt deleted file mode 100644 index ef69a4c393..0000000000 --- a/ext/reflection/tests/ReflectionClass_isInternal_error.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -ReflectionClass::isInternal() - invalid params ---FILE-- -<?php -$r1 = new ReflectionClass("stdClass"); -var_dump($r1->isInternal('X')); -var_dump($r1->isInternal('X', true)); -?> ---EXPECTF-- -Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 2 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt deleted file mode 100644 index 7d929fafd7..0000000000 --- a/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -ReflectionClass::isSubclassOf() - invalid number of parameters ---FILE-- -<?php -class A {} -$rc = new ReflectionClass('A'); - -var_dump($rc->isSubclassOf()); -var_dump($rc->isSubclassOf('A',5)); - -?> ---EXPECTF-- -Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 0 given in %s on line 5 -NULL - -Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 2 given in %s on line 6 -NULL diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_error2.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_error2.phpt new file mode 100644 index 0000000000..8671c2500b --- /dev/null +++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_error2.phpt @@ -0,0 +1,35 @@ +--TEST-- +ReflectionClass::isSubclassOf() - fixed crash for unbound anonymous class +--FILE-- +<?php +class X { + public static function main() { + return new class() extends Base {}; + } +} +class Base {} +$check = function () { + $base = Base::class; + foreach (get_declared_classes() as $class) { + if (strpos($class, 'class@anonymous') === false) { + continue; + } + echo "Checking for $class\n"; + flush(); + $rc = new ReflectionClass($class); + var_export($rc->isSubclassOf($base)); + echo "\n"; + } +}; +// Should not show up in get_declared_classes until the anonymous class is bound. +$check(); +echo "After first check\n"; +X::main(); +$check(); +echo "Done\n"; +?> +--EXPECTF-- +After first check +Checking for class@%s +true +Done diff --git a/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt b/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt deleted file mode 100644 index ac88884179..0000000000 --- a/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -ReflectionClass::isUserDefined() - invalid params. ---FILE-- -<?php -$r1 = new ReflectionClass("stdClass"); -var_dump($r1->isUserDefined('X')); -var_dump($r1->isUserDefined('X', true)); -?> ---EXPECTF-- -Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 2 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt index d82519e4f4..1370228f04 100644 --- a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt +++ b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt @@ -25,7 +25,7 @@ foreach ($classes as $class) { bool(false) bool(false) bool(true) -int(32) +int(64) bool(false) bool(false) bool(false) @@ -37,7 +37,7 @@ int(0) bool(true) bool(false) bool(false) -int(4) +int(32) bool(false) bool(true) bool(false) diff --git a/ext/reflection/tests/ReflectionClass_modifiers_002.phpt b/ext/reflection/tests/ReflectionClass_modifiers_002.phpt deleted file mode 100644 index a3a567ccbb..0000000000 --- a/ext/reflection/tests/ReflectionClass_modifiers_002.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Modifiers - wrong param count ---CREDITS-- -Robin Fernandes <robinf@php.net> -Steve Seear <stevseea@php.net> ---FILE-- -<?php -class C {} -$rc = new ReflectionClass("C"); -var_dump($rc->isFinal('X')); -var_dump($rc->isInterface(null)); -var_dump($rc->isAbstract(true)); -var_dump($rc->getModifiers(array(1,2,3))); - -?> ---EXPECTF-- -Warning: ReflectionClass::isFinal() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::isInterface() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::isAbstract() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getModifiers() expects exactly 0 parameters, 1 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt b/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt index 334efc3a50..59337f09e8 100644 --- a/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt +++ b/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt @@ -22,7 +22,19 @@ $class = new ReflectionClass('DateTime'); var_dump($class->newInstanceWithoutConstructor()); $class = new ReflectionClass('Generator'); +try { + var_dump($class->newInstanceWithoutConstructor()); +} catch (ReflectionException $e) { + echo $e->getMessage(), "\n"; +} + +final class Bar extends ArrayObject { +} + +$class = new ReflectionClass('Bar'); var_dump($class->newInstanceWithoutConstructor()); + +?> --EXPECTF-- object(Foo)#%d (0) { } @@ -30,9 +42,9 @@ object(stdClass)#%d (0) { } object(DateTime)#%d (0) { } - -Fatal error: Uncaught ReflectionException: Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor in %sReflectionClass_newInstanceWithoutConstructor.php:%d -Stack trace: -#0 %sReflectionClass_newInstanceWithoutConstructor.php(%d): ReflectionClass->newInstanceWithoutConstructor() -#1 {main} - thrown in %sReflectionClass_newInstanceWithoutConstructor.php on line %d +Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor +object(Bar)#%d (1) { + ["storage":"ArrayObject":private]=> + array(0) { + } +} diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt index 14e8382e41..fb472681ca 100644 --- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt +++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt @@ -1,5 +1,5 @@ --TEST-- -ReflectionClass::getStaticPropertyValue() - bad params +ReflectionClass::setStaticPropertyValue() - bad params --CREDITS-- Robin Fernandes <robinf@php.net> Steve Seear <stevseea@php.net> diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt new file mode 100644 index 0000000000..a83900a123 --- /dev/null +++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt @@ -0,0 +1,39 @@ +--TEST-- +ReflectionClass::setStaticPropertyValue() - type constraints must be enforced +--FILE-- +<?php + +class Test { + public static $x; + public static int $y = 2; +} + +$rc = new ReflectionClass('Test'); + +try { + $rc->setStaticPropertyValue("y", "foo"); +} catch (TypeError $e) { echo $e->getMessage(), "\n"; } +var_dump(Test::$y); + +$rc->setStaticPropertyValue("y", "21"); +var_dump(Test::$y); + + +Test::$x =& Test::$y; + +try { + $rc->setStaticPropertyValue("x", "foo"); +} catch (TypeError $e) { echo $e->getMessage(), "\n"; } +var_dump(Test::$y); + +$rc->setStaticPropertyValue("x", "42"); +var_dump(Test::$y); + +?> +--EXPECT-- +Typed property Test::$y must be int, string used +int(2) +int(21) +Cannot assign string to reference held by property Test::$y of type int +int(21) +int(42) diff --git a/ext/reflection/tests/ReflectionClass_toString_001.phpt b/ext/reflection/tests/ReflectionClass_toString_001.phpt index cafdd2e37c..2cfd808cb8 100644 --- a/ext/reflection/tests/ReflectionClass_toString_001.phpt +++ b/ext/reflection/tests/ReflectionClass_toString_001.phpt @@ -13,15 +13,15 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] { - Constants [3] { Constant [ public int IS_IMPLICIT_ABSTRACT ] { 16 } - Constant [ public int IS_EXPLICIT_ABSTRACT ] { 32 } - Constant [ public int IS_FINAL ] { 4 } + Constant [ public int IS_EXPLICIT_ABSTRACT ] { 64 } + Constant [ public int IS_FINAL ] { 32 } } - Static properties [0] { } - Static methods [1] { - Method [ <internal:Reflection, prototype Reflector> static public method export ] { + Method [ <internal, deprecated:Reflection> static public method export ] { - Parameters [2] { Parameter #0 [ <required> $argument ] diff --git a/ext/reflection/tests/ReflectionExtension_export_basic.phpt b/ext/reflection/tests/ReflectionExtension_export_basic.phpt index 3fa7a66afd..4652a409a1 100644 --- a/ext/reflection/tests/ReflectionExtension_export_basic.phpt +++ b/ext/reflection/tests/ReflectionExtension_export_basic.phpt @@ -5,18 +5,14 @@ Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php -ob_start(); ReflectionExtension::export("reflection", true); -$test = ob_get_clean(); -var_dump(empty($test)); -unset($test); ob_start(); ReflectionExtension::export("reflection", false); $test = ob_get_clean(); var_dump(empty($test)); ?> ==DONE== ---EXPECT-- -bool(true) +--EXPECTF-- +Deprecated: Function ReflectionExtension::export() is deprecated in %s on line %d bool(false) ==DONE== diff --git a/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt b/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt index 9b2122d1b9..5877f88e27 100644 --- a/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt +++ b/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt @@ -9,7 +9,7 @@ var_dump($ext->getClasses()); ?> ==DONE== --EXPECT-- -array(16) { +array(17) { ["ReflectionException"]=> object(ReflectionClass)#2 (1) { ["name"]=> @@ -90,5 +90,10 @@ array(16) { ["name"]=> string(23) "ReflectionZendExtension" } + ["ReflectionReference"]=> + object(ReflectionClass)#18 (1) { + ["name"]=> + string(19) "ReflectionReference" + } } ==DONE== diff --git a/ext/reflection/tests/ReflectionFunction_getClosure_error.phpt b/ext/reflection/tests/ReflectionFunction_getClosure_error.phpt deleted file mode 100644 index 9a963e41ca..0000000000 --- a/ext/reflection/tests/ReflectionFunction_getClosure_error.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Test ReflectionFunction::getClosure() function : error functionality ---FILE-- -<?php -/* Prototype : public mixed ReflectionFunction::getClosure() - * Description: Returns a dynamically created closure for the function - * Source code: ext/reflection/php_reflection.c - * Alias to functions: - */ - -echo "*** Testing ReflectionFunction::getClosure() : error conditions ***\n"; - -function foo() -{ - var_dump( "Inside foo function" ); -} - -$func = new ReflectionFunction( 'foo' ); -$closure = $func->getClosure('bar'); - -?> -===DONE=== ---EXPECTF-- -*** Testing ReflectionFunction::getClosure() : error conditions *** - -Warning: ReflectionFunction::getClosure() expects exactly 0 parameters, 1 given in %s on line %d -===DONE=== diff --git a/ext/reflection/tests/ReflectionMethod_basic2.phpt b/ext/reflection/tests/ReflectionMethod_basic2.phpt index c91af67701..71ef9e95d9 100644 --- a/ext/reflection/tests/ReflectionMethod_basic2.phpt +++ b/ext/reflection/tests/ReflectionMethod_basic2.phpt @@ -60,6 +60,8 @@ string(%d) "Method [ <user, inherits TestClass> public method foo ] { " export(): + +Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d string(%d) "Method [ <user, inherits TestClass> public method foo ] { @@ %s 16 - 18 } @@ -76,6 +78,8 @@ string(%d) "Method [ <user> static public method stat ] { " export(): + +Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d string(%d) "Method [ <user> static public method stat ] { @@ %s 20 - 22 } @@ -92,6 +96,8 @@ string(%d) "Method [ <user> private method priv ] { " export(): + +Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d string(%d) "Method [ <user> private method priv ] { @@ %s 24 - 26 } @@ -108,6 +114,8 @@ string(%d) "Method [ <user> protected method prot ] { " export(): + +Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d string(%d) "Method [ <user> protected method prot ] { @@ %s 28 - 28 } @@ -124,6 +132,8 @@ string(%d) "Method [ <user, inherits TestClass> protected method prot ] { " export(): + +Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d string(%d) "Method [ <user, inherits TestClass> protected method prot ] { @@ %s 28 - 28 } @@ -140,6 +150,8 @@ string(%d) "Method [ <user> abstract public method int ] { " export(): + +Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d string(%d) "Method [ <user> abstract public method int ] { @@ %s 36 - 36 } @@ -160,6 +172,8 @@ string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] { " export(): + +Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] { - Parameters [2] { @@ -180,6 +194,8 @@ string(%d) "Method [ <user, dtor> public method __destruct ] { " export(): + +Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d string(%d) "Method [ <user, dtor> public method __destruct ] { @@ %s 30 - 30 } diff --git a/ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt b/ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt deleted file mode 100644 index 02de25bab0..0000000000 --- a/ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -ReflectionMethod::getDocComment() errors ---FILE-- -<?php -class C { function f() {} } -$rc = new ReflectionMethod('C::f'); -var_dump($rc->getDocComment(null)); -var_dump($rc->getDocComment('X')); -?> ---EXPECTF-- -Warning: ReflectionFunctionAbstract::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionFunctionAbstract::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt index 55aea10763..d1a19c7116 100644 --- a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt @@ -87,151 +87,151 @@ printf("0x%08x\n", $a->getModifiers()); ?> --EXPECTF-- Modifiers for method TestClass::foo(): -0x00000100 +0x00000001 Modifiers for method TestClass::stat(): -0x00000101 +0x00000011 Modifiers for method TestClass::priv(): -0x00000400 +0x00000004 Modifiers for method TestClass::prot(): -0x00000200 +0x00000002 Modifiers for method TestClass::fin(): -0x00000104 +0x00000021 Modifiers for method TestClass::__destruct(): -0x00000100 +0x00000001 Modifiers for method TestClass::__call(): -0x00000100 +0x00000001 Modifiers for method TestClass::__clone(): -0x00000100 +0x00000001 Modifiers for method TestClass::__get(): -0x00000100 +0x00000001 Modifiers for method TestClass::__set(): -0x00000100 +0x00000001 Modifiers for method TestClass::__unset(): -0x00000100 +0x00000001 Modifiers for method TestClass::__isset(): -0x00000100 +0x00000001 Modifiers for method TestClass::__tostring(): -0x00000100 +0x00000001 Modifiers for method TestClass::__sleep(): -0x00000100 +0x00000001 Modifiers for method TestClass::__wakeup(): -0x00000100 +0x00000001 Modifiers for method TestClass::__set_state(): -0x00000100 +0x00000001 Modifiers for method TestClass::__autoload(): -0x00000100 +0x00000001 Modifiers for method TestClass::foo(): -0x00000100 +0x00000001 Modifiers for method TestClass::stat(): -0x00000101 +0x00000011 Modifiers for method TestClass::priv(): -0x00000400 +0x00000004 Modifiers for method TestClass::prot(): -0x00000200 +0x00000002 Modifiers for method TestClass::fin(): -0x00000104 +0x00000021 Modifiers for method TestClass::__destruct(): -0x00000100 +0x00000001 Modifiers for method TestClass::__call(): -0x00000100 +0x00000001 Modifiers for method TestClass::__clone(): -0x00000100 +0x00000001 Modifiers for method TestClass::__get(): -0x00000100 +0x00000001 Modifiers for method TestClass::__set(): -0x00000100 +0x00000001 Modifiers for method TestClass::__unset(): -0x00000100 +0x00000001 Modifiers for method TestClass::__isset(): -0x00000100 +0x00000001 Modifiers for method TestClass::__tostring(): -0x00000100 +0x00000001 Modifiers for method TestClass::__sleep(): -0x00000100 +0x00000001 Modifiers for method TestClass::__wakeup(): -0x00000100 +0x00000001 Modifiers for method TestClass::__set_state(): -0x00000100 +0x00000001 Modifiers for method TestClass::__autoload(): -0x00000100 +0x00000001 Modifiers for method TestInterface::int(): -0x00000102 +0x00000041 Modifiers for method TestInterface::__clone(): -0x00000102 +0x00000041 Modifiers for method AbstractClass::foo(): -0x00000102 +0x00000041 Wrong number of params: @@ -239,4 +239,4 @@ Wrong number of params: Warning: ReflectionMethod::getModifiers() expects exactly 0 parameters, 1 given in %s on line %d ReflectionMethod::getModifiers() modifiers: -0x00000100 +0x00000001 diff --git a/ext/reflection/tests/ReflectionNamedType.phpt b/ext/reflection/tests/ReflectionNamedType.phpt index a40d4066ec..afb592127c 100644 --- a/ext/reflection/tests/ReflectionNamedType.phpt +++ b/ext/reflection/tests/ReflectionNamedType.phpt @@ -30,12 +30,20 @@ var_dump($return->getName()); var_dump((string) $return); ?> ---EXPECT-- +--EXPECTF-- string(11) "Traversable" + +Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d string(11) "Traversable" string(6) "string" + +Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d string(6) "string" string(4) "Test" + +Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d string(4) "Test" string(4) "Test" + +Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d string(4) "Test" diff --git a/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt b/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt deleted file mode 100644 index 70ad24297d..0000000000 --- a/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -ReflectionObject::getFileName(), ReflectionObject::getStartLine(), ReflectionObject::getEndLine() -invalid aparams ---FILE-- -<?php -Class C { } - -$rc = new ReflectionObject(new C); -$methods = array("getFileName", "getStartLine", "getEndLine"); - -foreach ($methods as $method) { - var_dump($rc->$method()); - var_dump($rc->$method(null)); - var_dump($rc->$method('X', 0)); -} -?> ---EXPECTF-- -string(%d) "%s" - -Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 2 given in %s on line %d -NULL -int(2) - -Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 2 given in %s on line %d -NULL -int(2) - -Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 2 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionObject_constructor_error.phpt b/ext/reflection/tests/ReflectionObject_constructor_error.phpt deleted file mode 100644 index 71a1166b13..0000000000 --- a/ext/reflection/tests/ReflectionObject_constructor_error.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -ReflectionObject::__construct - invalid arguments ---FILE-- -<?php - -var_dump(new ReflectionObject()); -var_dump(new ReflectionObject('stdClass')); -$myInstance = new stdClass; -var_dump(new ReflectionObject($myInstance, $myInstance)); -var_dump(new ReflectionObject(0)); -var_dump(new ReflectionObject(null)); -var_dump(new ReflectionObject(array(1,2))); -?> ---EXPECTF-- -Warning: ReflectionObject::__construct() expects exactly 1 parameter, 0 given in %s on line 3 -object(ReflectionObject)#%d (1) { - ["name"]=> - string(0) "" -} - -Warning: ReflectionObject::__construct() expects parameter 1 to be object, string given in %s on line 4 -object(ReflectionObject)#%d (1) { - ["name"]=> - string(0) "" -} - -Warning: ReflectionObject::__construct() expects exactly 1 parameter, 2 given in %s on line 6 -object(ReflectionObject)#%d (1) { - ["name"]=> - string(0) "" -} - -Warning: ReflectionObject::__construct() expects parameter 1 to be object, int given in %s on line 7 -object(ReflectionObject)#%d (1) { - ["name"]=> - string(0) "" -} - -Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in %s on line 8 -object(ReflectionObject)#%d (1) { - ["name"]=> - string(0) "" -} - -Warning: ReflectionObject::__construct() expects parameter 1 to be object, array given in %s on line 9 -object(ReflectionObject)#%d (1) { - ["name"]=> - string(0) "" -} diff --git a/ext/reflection/tests/ReflectionObject_export_basic1.phpt b/ext/reflection/tests/ReflectionObject_export_basic1.phpt index 2fbe6fd779..43210ea686 100644 --- a/ext/reflection/tests/ReflectionObject_export_basic1.phpt +++ b/ext/reflection/tests/ReflectionObject_export_basic1.phpt @@ -1,5 +1,5 @@ --TEST-- -ReflectionObject::export() : very basic test with no dynamic properties +ReflectionObject::__toString() : very basic test with no dynamic properties --FILE-- <?php @@ -8,7 +8,7 @@ class Foo { } $f = new foo; -ReflectionObject::export($f); +echo new ReflectionObject($f); ?> --EXPECTF-- diff --git a/ext/reflection/tests/ReflectionObject_export_basic2.phpt b/ext/reflection/tests/ReflectionObject_export_basic2.phpt index 652a5556cd..970d07b432 100644 --- a/ext/reflection/tests/ReflectionObject_export_basic2.phpt +++ b/ext/reflection/tests/ReflectionObject_export_basic2.phpt @@ -1,5 +1,5 @@ --TEST-- -ReflectionObject::export() : very basic test with dynamic properties +ReflectionObject::__toString() : very basic test with dynamic properties --FILE-- <?php @@ -9,7 +9,7 @@ class Foo { $f = new foo; $f->dynProp = 'hello'; $f->dynProp2 = 'hello again'; -ReflectionObject::export($f); +echo new ReflectionObject($f); ?> --EXPECTF-- diff --git a/ext/reflection/tests/ReflectionObject_export_basic3.phpt b/ext/reflection/tests/ReflectionObject_export_basic3.phpt index c4afc22d64..a92c2d4921 100644 --- a/ext/reflection/tests/ReflectionObject_export_basic3.phpt +++ b/ext/reflection/tests/ReflectionObject_export_basic3.phpt @@ -1,5 +1,5 @@ --TEST-- -ReflectionObject::export() - ensure dynamic property with same name as inherited private property is shown. +ReflectionObject::__toString() - ensure dynamic property with same name as inherited private property is shown. --FILE-- <?php class C { @@ -11,7 +11,7 @@ class D extends C{ $Obj = new D; $Obj->p = 'value'; -ReflectionObject::export($Obj) +echo new ReflectionObject($Obj); ?> --EXPECTF-- Object of class [ <user> class D extends C ] { diff --git a/ext/reflection/tests/ReflectionObject_getConstant_error.phpt b/ext/reflection/tests/ReflectionObject_getConstant_error.phpt deleted file mode 100644 index 3f12f3a1ea..0000000000 --- a/ext/reflection/tests/ReflectionObject_getConstant_error.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -ReflectionObject::getConstant() - invalid params ---FILE-- -<?php -class C { - const myConst = 1; -} - -$rc = new ReflectionObject(new C); -var_dump($rc->getConstant()); -var_dump($rc->getConstant("myConst", "myConst")); -var_dump($rc->getConstant(null)); -var_dump($rc->getConstant(1)); -var_dump($rc->getConstant(1.5)); -var_dump($rc->getConstant(true)); -var_dump($rc->getConstant(array(1,2,3))); -var_dump($rc->getConstant(new C)); -?> ---EXPECTF-- -Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 0 given in %s on line 7 -NULL - -Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 2 given in %s on line 8 -NULL -bool(false) -bool(false) -bool(false) -bool(false) - -Warning: ReflectionClass::getConstant() expects parameter 1 to be string, array given in %s on line 13 -NULL - -Warning: ReflectionClass::getConstant() expects parameter 1 to be string, object given in %s on line 14 -NULL diff --git a/ext/reflection/tests/ReflectionObject_getConstants_error.phpt b/ext/reflection/tests/ReflectionObject_getConstants_error.phpt deleted file mode 100644 index d3b90805eb..0000000000 --- a/ext/reflection/tests/ReflectionObject_getConstants_error.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -ReflectionObject::getConstants() - invalid params ---FILE-- -<?php -class X { -} - -$rc = new ReflectionObject(new X); - -$rc->getConstants('X'); -$rc->getConstants(true); - -?> ---EXPECTF-- -Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d - -Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt b/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt deleted file mode 100644 index 2f52de2ed8..0000000000 --- a/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -ReflectionObject::getConstructor() - invalid params ---FILE-- -<?php -class C {} -$rc = new ReflectionObject(new C); -var_dump($rc->getConstructor(null)); -var_dump($rc->getConstructor('X')); -var_dump($rc->getConstructor(true)); -var_dump($rc->getConstructor(array(1,2,3))); -?> ---EXPECTF-- -Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionObject_getName_error.phpt b/ext/reflection/tests/ReflectionObject_getName_error.phpt deleted file mode 100644 index ff8e279e9b..0000000000 --- a/ext/reflection/tests/ReflectionObject_getName_error.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -ReflectionObject::getname() - invalid params ---FILE-- -<?php -class C { } -$myInstance = new C; -$r2 = new ReflectionObject($myInstance); - -$r3 = new ReflectionObject($r2); - -var_dump($r3->getName(null)); -var_dump($r3->getName('x','y')); -var_dump($r3->getName(0)); -?> ---EXPECTF-- -Warning: ReflectionClass::getName() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::getName() expects exactly 0 parameters, 2 given in %s on line %d -NULL - -Warning: ReflectionClass::getName() expects exactly 0 parameters, 1 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionObject_isInstance_error.phpt b/ext/reflection/tests/ReflectionObject_isInstance_error.phpt deleted file mode 100644 index fa0befa504..0000000000 --- a/ext/reflection/tests/ReflectionObject_isInstance_error.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -ReflectionObject::isInstance() - invalid params ---FILE-- -<?php -class X {} -$instance = new X; -$ro = new ReflectionObject(new X); - -var_dump($ro->isInstance()); -var_dump($ro->isInstance($instance, $instance)); -var_dump($ro->isInstance(1)); -var_dump($ro->isInstance(1.5)); -var_dump($ro->isInstance(true)); -var_dump($ro->isInstance('X')); -var_dump($ro->isInstance(null)); - -?> ---EXPECTF-- -Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 0 given in %s on line 6 -NULL - -Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 2 given in %s on line 7 -NULL - -Warning: ReflectionClass::isInstance() expects parameter 1 to be object, int given in %s on line 8 -NULL - -Warning: ReflectionClass::isInstance() expects parameter 1 to be object, float given in %s on line 9 -NULL - -Warning: ReflectionClass::isInstance() expects parameter 1 to be object, bool given in %s on line 10 -NULL - -Warning: ReflectionClass::isInstance() expects parameter 1 to be object, string given in %s on line 11 -NULL - -Warning: ReflectionClass::isInstance() expects parameter 1 to be object, null given in %s on line 12 -NULL diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt deleted file mode 100644 index f6d4c9d3d2..0000000000 --- a/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -ReflectionObject::IsInstantiable() - invalid params ---FILE-- -<?php -class privateCtorOld { - private function privateCtorOld() {} - public static function reflectionObjectFactory() { - return new ReflectionObject(new self); - } -} -$reflectionObject = privateCtorOld::reflectionObjectFactory(); - -var_dump($reflectionObject->IsInstantiable('X')); -var_dump($reflectionObject->IsInstantiable(0, null)); - -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d - -Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 2 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionObject_isInternal_error.phpt b/ext/reflection/tests/ReflectionObject_isInternal_error.phpt deleted file mode 100644 index 996add6cd4..0000000000 --- a/ext/reflection/tests/ReflectionObject_isInternal_error.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -ReflectionObject::isInternal() - invalid params ---FILE-- -<?php - -$r1 = new ReflectionObject(new stdClass); -var_dump($r1->isInternal('X')); -var_dump($r1->isInternal('X', true)); -?> ---EXPECTF-- -Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 2 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt b/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt deleted file mode 100644 index 06be47ae67..0000000000 --- a/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -ReflectionObject::isUserDefined() - invalid params ---FILE-- -<?php -$r1 = new ReflectionObject(new stdClass); - -var_dump($r1->isUserDefined('X')); -var_dump($r1->isUserDefined('X', true)); -?> ---EXPECTF-- -Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 2 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionParameter_export_basic.phpt b/ext/reflection/tests/ReflectionParameter_export_basic.phpt index 74428ccd23..6f3d16a5ff 100644 --- a/ext/reflection/tests/ReflectionParameter_export_basic.phpt +++ b/ext/reflection/tests/ReflectionParameter_export_basic.phpt @@ -1,5 +1,5 @@ --TEST-- -ReflectionParameter::export() +ReflectionParameter::__toString() --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- @@ -9,11 +9,11 @@ function ReflectionParameterTest($test, $test2 = null) { } $reflect = new ReflectionFunction('ReflectionParameterTest'); foreach($reflect->getParameters() as $key => $value) { - echo ReflectionParameter::export('ReflectionParameterTest', $key); + echo new ReflectionParameter('ReflectionParameterTest', $key), "\n"; } ?> ==DONE== ---EXPECT-- +--EXPECTF-- Parameter #0 [ <required> $test ] Parameter #1 [ <optional> $test2 = NULL ] ==DONE== diff --git a/ext/reflection/tests/ReflectionParameter_export_error.phpt b/ext/reflection/tests/ReflectionParameter_export_error.phpt deleted file mode 100644 index e3d2bac0fc..0000000000 --- a/ext/reflection/tests/ReflectionParameter_export_error.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -ReflectionParameter::export() without parameters ---CREDITS-- -Stefan Koopmanschap <stefan@stefankoopmanschap.nl> ---FILE-- -<?php -function ReflectionParameterTest($test, $test2 = null) { - echo $test; -} -$reflect = new ReflectionFunction('ReflectionParameterTest'); -foreach($reflect->getParameters() as $key => $value) { - ReflectionParameter::export(); -} -?> -==DONE== ---EXPECTF-- -Warning: ReflectionParameter::export() expects at least 2 parameters, 0 given in %s.php on line %d - -Warning: ReflectionParameter::export() expects at least 2 parameters, 0 given in %s.php on line %d -==DONE== diff --git a/ext/reflection/tests/ReflectionParameter_export_error2.phpt b/ext/reflection/tests/ReflectionParameter_export_error2.phpt index aa0bc0aa7c..38cd99171b 100644 --- a/ext/reflection/tests/ReflectionParameter_export_error2.phpt +++ b/ext/reflection/tests/ReflectionParameter_export_error2.phpt @@ -26,6 +26,9 @@ catch (ReflectionException $e) { echo $e->getMessage() . "\n"; } ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Function ReflectionParameter::export() is deprecated in %s on line %d Method ReflectionFunction::__invoke() does not exist + +Deprecated: Function ReflectionParameter::export() is deprecated in %s on line %d The parameter class is expected to be either a string, an array(class, method) or a callable object diff --git a/ext/reflection/tests/ReflectionParameter_export_error3.phpt b/ext/reflection/tests/ReflectionParameter_export_error3.phpt index f5223c35fe..b098a9251d 100644 --- a/ext/reflection/tests/ReflectionParameter_export_error3.phpt +++ b/ext/reflection/tests/ReflectionParameter_export_error3.phpt @@ -13,9 +13,11 @@ foreach($params as $key => $value) { ReflectionParameter::export('ReflectionParameterTest', 'incorrect_parameter'); } --EXPECTF-- -Fatal error: Uncaught ReflectionException: The parameter specified by its name could not be found in %s.php:%d +Deprecated: Function ReflectionParameter::export() is deprecated in %s on line %d + +Fatal error: Uncaught ReflectionException: The parameter specified by its name could not be found in %s:%d Stack trace: #0 [internal function]: ReflectionParameter->__construct('ReflectionParam...', 'incorrect_param...') -#1 %s.php(%d): ReflectionParameter::export('ReflectionParam...', 'incorrect_param...') +#1 %s(%d): ReflectionParameter::export('ReflectionParam...', 'incorrect_param...') #2 {main} - thrown in %s.php on line %d + thrown in %s on line %d diff --git a/ext/reflection/tests/ReflectionProperty_basic1.phpt b/ext/reflection/tests/ReflectionProperty_basic1.phpt index 18eb71fa10..1748ebfca9 100644 --- a/ext/reflection/tests/ReflectionProperty_basic1.phpt +++ b/ext/reflection/tests/ReflectionProperty_basic1.phpt @@ -47,7 +47,7 @@ reflectProperty("TestClass", "prot"); reflectProperty("TestClass", "priv"); ?> ---EXPECT-- +--EXPECTF-- ********************************** Reflecting on property TestClass::pub @@ -55,9 +55,13 @@ __toString(): string(35) "Property [ <default> public $pub ] " export(): + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d string(35) "Property [ <default> public $pub ] " export(): + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d Property [ <default> public $pub ] NULL @@ -84,9 +88,13 @@ __toString(): string(33) "Property [ public static $stat ] " export(): + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d string(33) "Property [ public static $stat ] " export(): + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d Property [ public static $stat ] NULL @@ -113,9 +121,13 @@ __toString(): string(39) "Property [ <default> protected $prot ] " export(): + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d string(39) "Property [ <default> protected $prot ] " export(): + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d Property [ <default> protected $prot ] NULL @@ -138,9 +150,13 @@ __toString(): string(37) "Property [ <default> private $priv ] " export(): + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d string(37) "Property [ <default> private $priv ] " export(): + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d Property [ <default> private $priv ] NULL diff --git a/ext/reflection/tests/ReflectionProperty_basic2.phpt b/ext/reflection/tests/ReflectionProperty_basic2.phpt index 0491073ace..09495f744b 100644 --- a/ext/reflection/tests/ReflectionProperty_basic2.phpt +++ b/ext/reflection/tests/ReflectionProperty_basic2.phpt @@ -43,7 +43,7 @@ Reflecting on property TestClass::pub isDefault(): bool(true) getModifiers(): -int(256) +int(1) getDeclaringClass(): object(ReflectionClass)#%d (1) { ["name"]=> @@ -59,7 +59,7 @@ Reflecting on property TestClass::stat isDefault(): bool(true) getModifiers(): -int(257) +int(17) getDeclaringClass(): object(ReflectionClass)#%d (1) { ["name"]=> @@ -75,7 +75,7 @@ Reflecting on property TestClass::prot isDefault(): bool(true) getModifiers(): -int(512) +int(2) getDeclaringClass(): object(ReflectionClass)#%d (1) { ["name"]=> @@ -93,7 +93,7 @@ Reflecting on property TestClass::priv isDefault(): bool(true) getModifiers(): -int(1024) +int(4) getDeclaringClass(): object(ReflectionClass)#%d (1) { ["name"]=> diff --git a/ext/reflection/tests/ReflectionProperty_export_basic.phpt b/ext/reflection/tests/ReflectionProperty_export_basic.phpt index e77a3b714a..28f1f6b988 100644 --- a/ext/reflection/tests/ReflectionProperty_export_basic.phpt +++ b/ext/reflection/tests/ReflectionProperty_export_basic.phpt @@ -1,5 +1,5 @@ --TEST-- -Test ReflectionProperty::export() usage. +Test ReflectionProperty::__toString() usage. --FILE-- <?php @@ -7,10 +7,8 @@ class TestClass { public $proper = 5; } -var_dump(ReflectionProperty::export('TestClass', 'proper')); +echo new ReflectionProperty('TestClass', 'proper'); ?> --EXPECT-- Property [ <default> public $proper ] - -NULL diff --git a/ext/reflection/tests/ReflectionProperty_export_error.phpt b/ext/reflection/tests/ReflectionProperty_export_error.phpt index ab09ed01f0..114b4c0ac8 100644 --- a/ext/reflection/tests/ReflectionProperty_export_error.phpt +++ b/ext/reflection/tests/ReflectionProperty_export_error.phpt @@ -39,16 +39,26 @@ ReflectionProperty::export('TestClass', "nonExistentProperty", true, false); ?> --EXPECTF-- Non-existent class: + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d Class NonExistentClass does not exist Wrong property parameter type: + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d The parameter class is expected to be either a string or an object Non-existent property: + +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d Property TestClass::$nonExistentProperty does not exist Incorrect number of args: +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d + Warning: ReflectionProperty::export() expects at least 2 parameters, 0 given in %s on line %d +Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d + Warning: ReflectionProperty::export() expects at most 3 parameters, 4 given in %s on line %d diff --git a/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt b/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt deleted file mode 100644 index dae7be2fb9..0000000000 --- a/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -Test ReflectionProperty::getDocComment() errors. ---FILE-- -<?php - -class C { - public $a; -} - -$rc = new ReflectionProperty('C', 'a'); -var_dump($rc->getDocComment(null)); -var_dump($rc->getDocComment('X')); -var_dump($rc->getDocComment(true)); -var_dump($rc->getDocComment(array(1, 2, 3))); - -?> ---EXPECTF-- -Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d -NULL - -Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d -NULL diff --git a/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt b/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt index 6d7ddbe834..a297a10436 100644 --- a/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt +++ b/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt @@ -40,27 +40,27 @@ reflectProperty("TestClass", "priv"); Reflecting on property TestClass::pub getModifiers(): -int(256) +int(1) ********************************** ********************************** Reflecting on property TestClass::stat getModifiers(): -int(257) +int(17) ********************************** ********************************** Reflecting on property TestClass::prot getModifiers(): -int(512) +int(2) ********************************** ********************************** Reflecting on property TestClass::priv getModifiers(): -int(1024) +int(4) ********************************** diff --git a/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt index 4c99444e30..6856569d3e 100644 --- a/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt @@ -32,15 +32,15 @@ for ($i = 1;$i <= 6;$i++) { ?> --EXPECT-- -C::a1: int(256) -D::a1: int(256) -C::a2: int(512) -D::a2: int(512) -C::a3: int(1024) -D::a3: int(1024) -C::a4: int(257) -D::a4: int(257) -C::a5: int(513) -D::a5: int(513) -C::a6: int(1025) -D::a6: int(1025) +C::a1: int(1) +D::a1: int(1) +C::a2: int(2) +D::a2: int(2) +C::a3: int(4) +D::a3: int(4) +C::a4: int(17) +D::a4: int(17) +C::a5: int(18) +D::a5: int(18) +C::a6: int(20) +D::a6: int(20) diff --git a/ext/reflection/tests/ReflectionProperty_isInitialized.phpt b/ext/reflection/tests/ReflectionProperty_isInitialized.phpt new file mode 100644 index 0000000000..f1f6e53ebd --- /dev/null +++ b/ext/reflection/tests/ReflectionProperty_isInitialized.phpt @@ -0,0 +1,113 @@ +--TEST-- +Test ReflectionProperty::isInitialized() +--FILE-- +<?php + +class A { + public static ?string $ssv = null; + public static ?string $ss; + public static $s; + public ?int $iv = null; + public ?int $i; + public $n; + + private int $p; +} + +class B extends A { } + +echo "Static properties:\n"; +var_dump((new ReflectionProperty(A::class, 'ssv'))->isInitialized()); +var_dump((new ReflectionProperty(A::class, 'ss'))->isInitialized()); +var_dump((new ReflectionProperty(A::class, 's'))->isInitialized()); + +echo "Declared properties:\n"; +$a = new A; +var_dump((new ReflectionProperty($a, 'iv'))->isInitialized($a)); +var_dump((new ReflectionProperty($a, 'i'))->isInitialized($a)); +var_dump((new ReflectionProperty($a, 'n'))->isInitialized($a)); + +echo "Declared properties after unset:\n"; +unset($a->iv); +unset($a->i); +unset($a->n); +var_dump((new ReflectionProperty($a, 'i'))->isInitialized($a)); +var_dump((new ReflectionProperty($a, 'iv'))->isInitialized($a)); +var_dump((new ReflectionProperty($a, 'n'))->isInitialized($a)); + +echo "Dynamic properties:\n"; +$a->d = null; +$rp = new ReflectionProperty($a, 'd'); +var_dump($rp->isInitialized($a)); +unset($a->d); +var_dump($rp->isInitialized($a)); + +echo "Visibility handling:\n"; +$rp = new ReflectionProperty('A', 'p'); +try { + var_dump($rp->isInitialized($a)); +} catch (ReflectionException $e) { + echo $e->getMessage(), "\n"; +} +$rp->setAccessible(true); +var_dump($rp->isInitialized($a)); + +echo "Object type:\n"; +$rp = new ReflectionProperty('B', 'i'); +var_dump($rp->isInitialized($a)); + +try { + var_dump($rp->isInitialized(new stdClass)); +} catch (ReflectionException $e) { + echo $e->getMessage(), "\n"; +} + +class WithMagic { + public $prop; + public int $intProp; + + public function __isset($name) { + echo "__isset($name)\n"; + return true; + } + + public function __get($name) { + echo "__get($name)\n"; + return "foobar"; + } +} + +echo "Class with __isset:\n"; +$obj = new WithMagic; +unset($obj->prop); +$rp = new ReflectionProperty('WithMagic', 'prop'); +var_dump($rp->isInitialized($obj)); +$rp = new ReflectionProperty('WithMagic', 'intProp'); +var_dump($rp->isInitialized($obj)); + +?> +--EXPECT-- +Static properties: +bool(true) +bool(false) +bool(true) +Declared properties: +bool(true) +bool(false) +bool(true) +Declared properties after unset: +bool(false) +bool(false) +bool(false) +Dynamic properties: +bool(true) +bool(false) +Visibility handling: +Cannot access non-public member A::$p +bool(false) +Object type: +bool(false) +Given object is not an instance of the class this property was declared in +Class with __isset: +bool(false) +bool(false) diff --git a/ext/reflection/tests/ReflectionProperty_typed_static.phpt b/ext/reflection/tests/ReflectionProperty_typed_static.phpt new file mode 100644 index 0000000000..77f95d77ef --- /dev/null +++ b/ext/reflection/tests/ReflectionProperty_typed_static.phpt @@ -0,0 +1,51 @@ +--TEST-- +ReflectionProperty::getValue() on typed static property +--FILE-- +<?php + +class Test { + public static int $x = 42; + public static int $y; + public static $z; +} + +$rp = new ReflectionProperty('Test', 'x'); +var_dump($rp->getValue()); + +$rp = new ReflectionProperty('Test', 'y'); +try { + var_dump($rp->getValue()); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +$rp->setValue("24"); +var_dump($rp->getValue()); + +try { + $rp->setValue("foo"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +var_dump($rp->getValue()); + +Test::$z =& Test::$y; + +$rp = new ReflectionProperty('Test', 'z'); +try { + $rp->setValue("foo"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +var_dump($rp->getValue()); + + +?> +--EXPECT-- +int(42) +Typed static property Test::$y must not be accessed before initialization +int(24) +Typed property Test::$y must be int, string used +int(24) +Cannot assign string to reference held by property Test::$y of type int +int(24) diff --git a/ext/reflection/tests/ReflectionReference.phpt b/ext/reflection/tests/ReflectionReference.phpt new file mode 100644 index 0000000000..2963c30232 --- /dev/null +++ b/ext/reflection/tests/ReflectionReference.phpt @@ -0,0 +1,59 @@ +--TEST-- +Basic ReflectionReference functionality +--FILE-- +<?php + +$ary = [0, 1, 2, 3]; +$ref1 =& $ary[1]; +unset($ref1); +$ref2 =& $ary[2]; +$ref3 =& $ary[3]; + +echo "fromArrayElement():\n"; +$r0 = ReflectionReference::fromArrayElement($ary, 0); +var_dump($r0 === null); +$r1 = ReflectionReference::fromArrayElement($ary, 1); +var_dump($r1 === null); +$r2 = ReflectionReference::fromArrayElement($ary, 2); +var_dump($r2 instanceof ReflectionReference); +$r3 = ReflectionReference::fromArrayElement($ary, 3); +var_dump($r2 instanceof ReflectionReference); + +echo "getId() #1:\n"; +var_dump($r2->getId() === $r2->getId()); +var_dump($r3->getId() === $r3->getId()); +var_dump($r2->getId() !== $r3->getId()); + +echo "getId() #2:\n"; +$ary2 = [&$ary[2], &$ref3]; +$r2_2 = ReflectionReference::fromArrayElement($ary2, 0); +$r3_2 = ReflectionReference::fromArrayElement($ary2, 1); +var_dump($r2->getId() === $r2_2->getId()); +var_dump($r3->getId() === $r3_2->getId()); + +echo "getId() #3:\n"; +$r2_id = $r2->getId(); +$r3_id = $r3->getId(); +unset($r0, $r1, $r2, $r3, $r2_2, $r3_2); +$r2 = ReflectionReference::fromArrayElement($ary, 2); +$r3 = ReflectionReference::fromArrayElement($ary, 3); +var_dump($r2_id === $r2->getId()); +var_dump($r3_id === $r3->getId()); + +?> +--EXPECT-- +fromArrayElement(): +bool(true) +bool(true) +bool(true) +bool(true) +getId() #1: +bool(true) +bool(true) +bool(true) +getId() #2: +bool(true) +bool(true) +getId() #3: +bool(true) +bool(true) diff --git a/ext/reflection/tests/ReflectionReference_bug78263.phpt b/ext/reflection/tests/ReflectionReference_bug78263.phpt new file mode 100644 index 0000000000..868edc0812 --- /dev/null +++ b/ext/reflection/tests/ReflectionReference_bug78263.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #78263: Handling of self-referential array special case +--FILE-- +<?php + +// The case of a directly self-referential array is special and will +// be treated as a proper reference despite rc=1 during array copying. +$a = [&$a]; +$b = [$a]; +unset($a); + +var_dump(ReflectionReference::fromArrayElement($b[0], 0)); + +?> +--EXPECT-- +object(ReflectionReference)#1 (0) { +} diff --git a/ext/reflection/tests/ReflectionReference_errors.phpt b/ext/reflection/tests/ReflectionReference_errors.phpt new file mode 100644 index 0000000000..8e52a1d223 --- /dev/null +++ b/ext/reflection/tests/ReflectionReference_errors.phpt @@ -0,0 +1,52 @@ +--TEST-- +Various error conditions for ReflectionReference +--FILE-- +<?php + +try { + new ReflectionReference(); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +try { + ReflectionReference::fromArrayElement(new stdClass, "test"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} + +try { + ReflectionReference::fromArrayElement([], 1.5); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} + +try { + $ary = [0, 1, 2]; + ReflectionReference::fromArrayElement($ary, 3); +} catch (ReflectionException $e) { + echo $e->getMessage(), "\n"; +} + +try { + $ary = [&$ary]; + $ref = ReflectionReference::fromArrayElement($ary, 0); + var_dump(serialize($ref)); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +var_dump(unserialize('O:19:"ReflectionReference":0:{}')); + +?> +--EXPECTF-- +Call to private ReflectionReference::__construct() from invalid context +ReflectionReference::fromArrayElement() expects parameter 1 to be array, object given +Key must be array or string +Array key not found +Serialization of 'ReflectionReference' is not allowed + +Warning: Erroneous data format for unserializing 'ReflectionReference' in %s on line %d + +Notice: unserialize(): Error at offset 30 of 31 bytes in %s on line %d +bool(false) diff --git a/ext/reflection/tests/ReflectionType_001.phpt b/ext/reflection/tests/ReflectionType_001.phpt index d949e18107..1eb521317c 100644 --- a/ext/reflection/tests/ReflectionType_001.phpt +++ b/ext/reflection/tests/ReflectionType_001.phpt @@ -74,6 +74,32 @@ foreach ([ } } +echo "\n*** property types\n"; + +class PropTypeTest { + public int $int; + public string $string; + public array $arr; + public iterable $iterable; + public stdClass $std; + public OtherThing $other; + public $mixed; +} + +$reflector = new ReflectionClass(PropTypeTest::class); + +foreach ($reflector->getProperties() as $name => $property) { + if ($property->hasType()) { + printf("public %s $%s;\n", + $property->getType()->getName(), $property->getName()); + } else printf("public $%s;\n", $property->getName()); +} + +echo "*** resolved property types\n"; +$obj = new PropTypeTest; +$obj->std = new stdClass; +$r = (new ReflectionProperty($obj, 'std'))->getType(); +var_dump($r->getName()); ?> --EXPECT-- *** functions @@ -185,3 +211,14 @@ bool(true) bool(false) bool(false) string(4) "Test" + +*** property types +public int $int; +public string $string; +public array $arr; +public iterable $iterable; +public stdClass $std; +public OtherThing $other; +public $mixed; +*** resolved property types +string(8) "stdClass" diff --git a/ext/reflection/tests/ReflectionZendExtension.phpt b/ext/reflection/tests/ReflectionZendExtension.phpt index b4cd96e97b..bce34f5a2c 100644 --- a/ext/reflection/tests/ReflectionZendExtension.phpt +++ b/ext/reflection/tests/ReflectionZendExtension.phpt @@ -16,8 +16,10 @@ var_dump(gettype($reflection->export('Zend OPcache', true)) === 'string'); ?> --EXPECTF-- string(17) "Zend Technologies" -string(23) "Copyright (c) 1999-20%d" +string(13) "Copyright (c)" string(12) "Zend OPcache" string(20) "http://www.zend.com/" bool(true) + +Deprecated: Function ReflectionZendExtension::export() is deprecated in %s on line %d bool(true) diff --git a/ext/reflection/tests/bug29986.phpt b/ext/reflection/tests/bug29986.phpt index 3d8d6ee7c5..97aafd3820 100644 --- a/ext/reflection/tests/bug29986.phpt +++ b/ext/reflection/tests/bug29986.phpt @@ -13,7 +13,7 @@ class just_constants const FLOAT_CONSTANT = 3.14159265; } -Reflection::export(new ReflectionClass('just_constants')); +echo new ReflectionClass('just_constants'); ?> --EXPECTF-- Class [ <user> class just_constants ] { diff --git a/ext/reflection/tests/bug33389.phpt b/ext/reflection/tests/bug33389.phpt index f1997a397c..fb166c16ba 100644 --- a/ext/reflection/tests/bug33389.phpt +++ b/ext/reflection/tests/bug33389.phpt @@ -19,10 +19,7 @@ class Test { function foo() { } } -Reflection::export(new ReflectionClass('Test')); -?> -===DONE=== -<?php exit(0); ?> +echo new ReflectionClass('Test'); --EXPECTF-- Class [ <user> class Test ] { @@ %sbug33389.php 3-18 @@ -93,5 +90,3 @@ Class [ <user> class Test ] { } } } - -===DONE=== diff --git a/ext/reflection/tests/bug37964.phpt b/ext/reflection/tests/bug37964.phpt index f3c161da8d..f3ebe9f72a 100644 --- a/ext/reflection/tests/bug37964.phpt +++ b/ext/reflection/tests/bug37964.phpt @@ -19,7 +19,7 @@ class bar extends foo { } } -Reflection::export(new ReflectionClass(new bar)); +echo new ReflectionClass(new bar); ?> --EXPECTF-- diff --git a/ext/reflection/tests/bug38942.phpt b/ext/reflection/tests/bug38942.phpt index 59666607cb..6dbe396ae6 100644 --- a/ext/reflection/tests/bug38942.phpt +++ b/ext/reflection/tests/bug38942.phpt @@ -8,7 +8,7 @@ class foo { class bar extends foo { } -ReflectionClass::export("bar"); +echo new ReflectionClass("bar"); ?> --EXPECTF-- Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in %s on line %d diff --git a/ext/reflection/tests/bug41061.phpt b/ext/reflection/tests/bug41061.phpt index d907907dcf..027b872be9 100644 --- a/ext/reflection/tests/bug41061.phpt +++ b/ext/reflection/tests/bug41061.phpt @@ -1,5 +1,5 @@ --TEST-- -Reflection Bug #41061 ("visibility error" in ReflectionFunction::export()) +Reflection Bug #41061 ("visibility error" in ReflectionFunction::__toString()) --FILE-- <?php @@ -11,8 +11,8 @@ class bar { } } -Reflection::export(new ReflectionFunction('foo')); -Reflection::export(new ReflectionMethod('bar', 'foo')); +echo new ReflectionFunction('foo'), "\n"; +echo new ReflectionMethod('bar', 'foo'), "\n"; ?> ===DONE=== <?php exit(0); ?> diff --git a/ext/reflection/tests/bug45571.phpt b/ext/reflection/tests/bug45571.phpt index 2aa5698879..74245fc24c 100644 --- a/ext/reflection/tests/bug45571.phpt +++ b/ext/reflection/tests/bug45571.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #45571 (ReflectionClass::export() shows superclasses' private static methods.) +Bug #45571 (ReflectionClass::__toString() shows superclasses' private static methods.) --FILE-- <?php @@ -14,7 +14,7 @@ Class A { Class C extends A { } -ReflectionClass::export("C"); +echo new ReflectionClass("C"); ?> --EXPECTF-- diff --git a/ext/reflection/tests/bug45765.phpt b/ext/reflection/tests/bug45765.phpt index 80cb39d0ac..5c33faca2b 100644 --- a/ext/reflection/tests/bug45765.phpt +++ b/ext/reflection/tests/bug45765.phpt @@ -23,7 +23,7 @@ class foo extends foo2 { } } -ReflectionObject::export(new foo); +echo new ReflectionObject(new foo); ?> --EXPECTF-- diff --git a/ext/reflection/tests/bug46205.phpt b/ext/reflection/tests/bug46205.phpt index ef7a692cb7..5ca8ac1cd0 100644 --- a/ext/reflection/tests/bug46205.phpt +++ b/ext/reflection/tests/bug46205.phpt @@ -10,5 +10,6 @@ try { } catch (Exception $e) { } ?> ok ---EXPECT-- +--EXPECTF-- +Deprecated: Function ReflectionParameter::export() is deprecated in %s on line %d ok diff --git a/ext/reflection/tests/bug49719.phpt b/ext/reflection/tests/bug49719.phpt index f55334c951..6211b6b543 100644 --- a/ext/reflection/tests/bug49719.phpt +++ b/ext/reflection/tests/bug49719.phpt @@ -36,7 +36,7 @@ $prop->setAccessible(true); var_dump($prop->getValue(new b2)); ?> ---EXPECTF-- +--EXPECT-- bool(false) bool(false) bool(false) diff --git a/ext/reflection/tests/bug61388.phpt b/ext/reflection/tests/bug61388.phpt index 3d6dc83fa0..b9fe6bfaaa 100644 --- a/ext/reflection/tests/bug61388.phpt +++ b/ext/reflection/tests/bug61388.phpt @@ -14,12 +14,6 @@ print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC)); --EXPECT-- Array ( - [0] => ReflectionProperty Object - ( - [name] => test - [class] => ArrayObject - ) - ) Array ( diff --git a/ext/reflection/tests/bug72661.phpt b/ext/reflection/tests/bug72661.phpt index b1cb764beb..46ba048078 100644 --- a/ext/reflection/tests/bug72661.phpt +++ b/ext/reflection/tests/bug72661.phpt @@ -6,5 +6,6 @@ function test(iterable $arg) { } var_dump((string)(new ReflectionParameter("test", 0))->getType()); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d string(8) "iterable" diff --git a/ext/reflection/tests/bug74454.phpt b/ext/reflection/tests/bug74454.phpt index d2d6e88649..9e0332d893 100644 --- a/ext/reflection/tests/bug74454.phpt +++ b/ext/reflection/tests/bug74454.phpt @@ -14,6 +14,6 @@ function load_file() { } ?> ===DONE=== ---EXPECTF-- +--EXPECT-- ParseError: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) or const (T_CONST) ===DONE=== diff --git a/ext/reflection/tests/bug74673.phpt b/ext/reflection/tests/bug74673.phpt index 8e4e8e3a18..47f7604e8b 100644 --- a/ext/reflection/tests/bug74673.phpt +++ b/ext/reflection/tests/bug74673.phpt @@ -19,4 +19,9 @@ $class = new ReflectionClass('A'); echo $class; ?> --EXPECTF-- -Fatal error: Method ReflectionClass::__toString() must not throw an exception, caught Exception: in %sbug74673.php on line %d +Fatal error: Uncaught Exception in %s:%d +Stack trace: +#0 [internal function]: {closure}(2, 'Use of undefine...', %s, %d, Array) +#1 %s(%d): ReflectionClass->__toString() +#2 {main} + thrown in %s on line %d diff --git a/ext/reflection/tests/bug76737.phpt b/ext/reflection/tests/bug76737.phpt new file mode 100644 index 0000000000..716b40e76a --- /dev/null +++ b/ext/reflection/tests/bug76737.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #76737: Unserialized reflection objects are broken, they shouldn't be serializable +--FILE-- +<?php + +try { + $r = new ReflectionClass('stdClass'); + var_dump(serialize($r)); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} +try { + $s = 'C:15:"ReflectionClass":0:{}'; + var_dump(unserialize($s)); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} +try { + $s = 'O:15:"ReflectionClass":0:{}'; + var_dump(unserialize($s)); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECTF-- +Serialization of 'ReflectionClass' is not allowed +Unserialization of 'ReflectionClass' is not allowed + +Warning: Erroneous data format for unserializing 'ReflectionClass' in %s on line %d + +Notice: unserialize(): Error at offset 26 of 27 bytes in %s on line %d +bool(false) diff --git a/ext/reflection/tests/exception.inc b/ext/reflection/tests/exception.inc deleted file mode 100644 index da3fceaac7..0000000000 --- a/ext/reflection/tests/exception.inc +++ /dev/null @@ -1,16 +0,0 @@ -<?php -class ReflectionExceptionEx extends ReflectionException { - function MyException($_errno, $_errmsg) { - $this->errno = $_errno; - $this->errmsg = $_errmsg; - } - - function getErrno() { - return $this->errno; - } - - function getErrmsg() { - return $this->errmsg; - } -} -?> diff --git a/ext/reflection/tests/traits002.phpt b/ext/reflection/tests/traits002.phpt index 3a4b294961..c7a09bfb19 100644 --- a/ext/reflection/tests/traits002.phpt +++ b/ext/reflection/tests/traits002.phpt @@ -10,8 +10,8 @@ trait bar { } -reflectionclass::export('foo'); -reflectionclass::export('bar'); +echo new ReflectionClass('foo'), "\n"; +echo new ReflectionClass('bar'), "\n"; ?> --EXPECTF-- |
