--TEST--
ReflectionMethod::__toString() tests (overriden method)
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class Foo {
$m = new ReflectionMethod("Bar::func");
echo $m;
?>
---EXPECTF--
+--EXPECTF--
Method [ <user, overwrites Foo, prototype Foo> public method func ] {
@@ %s010.php 7 - 8
}
--TEST--
ReflectionExtension::getClasses()
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
$ext = new ReflectionExtension("reflection");
$classes = $ext->getClasses();
echo $classes["ReflectionException"]->getName();
?>
---EXPECT--
+--EXPECT--
ReflectionException
--TEST--
ReflectionClass::getDefaultProperties()
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class Foo {
$props = $class->getDefaultProperties();
echo $props["test"];
?>
---EXPECT--
+--EXPECT--
ok
-
--TEST--
ReflectionExtension::getFunctions()
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
$ext = new ReflectionExtension("standard");
$funcs = $ext->getFunctions();
echo $funcs["sleep"]->getName();
?>
---EXPECT--
+--EXPECT--
sleep
-
--TEST--
ReflectionExtension::getConstants()
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
$ext = new ReflectionExtension("standard");
$consts = $ext->getConstants();
var_dump($consts["CONNECTION_NORMAL"]);
?>
---EXPECT--
+--EXPECT--
int(0)
-
--TEST--
ReflectionExtension::getINIEntries()
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--INI--
user_agent=php
--FILE--
$inis = $ext->getINIEntries();
var_dump($inis["user_agent"]);
?>
---EXPECT--
+--EXPECT--
string(3) "php"
-
ReflectionExtension::getDependencies()
--SKIPIF--
<?php
-extension_loaded('reflection') or die('skip');
if (!extension_loaded("xml")) {
die('skip xml extension not available');
}
$deps = $ext->getDependencies();
var_dump($deps);
?>
---EXPECT--
+--EXPECT--
array(1) {
["libxml"]=>
string(8) "Required"
--TEST--
ReflectionClass::__toString() (constants)
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class Foo {
- Methods [0] {
}
}
-
--TEST--
Reflection::getModifierNames
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
var_dump(Reflection::getModifierNames(ReflectionMethod::IS_FINAL | ReflectionMethod::IS_PROTECTED));
?>
---EXPECT--
+--EXPECT--
array(2) {
[0]=>
string(5) "final"
--TEST--
ReflectionFunction::getExtensionName
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
$f = new ReflectionFunction("sleep");
var_dump($f->getExtensionName());
?>
---EXPECT--
+--EXPECT--
string(8) "standard"
--TEST--
ReflectionObject::hasProperty
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class Foo {
var_dump($obj->hasProperty("p3"));
var_dump($obj->hasProperty("p4"));
?>
---EXPECT--
+--EXPECT--
bool(true)
bool(true)
bool(true)
--TEST--
ReflectionClass::hasConstant
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class Foo {
var_dump($class->hasConstant("c1"));
var_dump($class->hasConstant("c2"));
?>
---EXPECT--
+--EXPECT--
bool(true)
bool(false)
--TEST--
ReflectionClass::getConstant
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class Foo {
var_dump($class->getConstant("c1"));
var_dump($class->getConstant("c2"));
?>
---EXPECT--
+--EXPECT--
int(1)
bool(false)
--TEST--
ReflectionClass::getDefaultProperties (filtering parent privates)
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class C1 {
$class = new ReflectionClass("C2");
var_dump($class->getDefaultProperties());
?>
---EXPECT--
+--EXPECT--
array(5) {
["p4"]=>
int(4)
--TEST--
ReflectionObject::__toString (filtering privates/protected dynamic properties)
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class C1 {
$obj = new ReflectionObject($x);
echo $obj;
?>
---EXPECTF--
+--EXPECTF--
Object of class [ <user> class C1 ] {
@@ %s024.php 2-6
--TEST--
ReflectionFunction basic tests
---SKIPIF--
-<?php extension_loaded('reflection') or die('skip'); ?>
--INI--
opcache.save_comments=1
--FILE--
echo "Done\n";
?>
---EXPECTF--
+--EXPECTF--
/**
hoho
*/
--CREDITS--
Stefan Koopmanschap <stefan@phpgg.nl>
TestFest PHP|Tek
---SKIPIF--
-<?php
-if (!extension_loaded('reflection')) print 'skip';
-?>
---FILE--
+--FILE--
<?php
$rc = new ReflectionClass("stdClass");
$rc2 = clone($rc);
+?>
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class ReflectionClass in %s:%d
Stack trace:
ReflectionExtension::getFunctions() ##6218 zend_register_functions breaks reflection
--SKIPIF--
<?php
-if (!extension_loaded('reflection')) print 'skip missing reflection extension';
if (PHP_SAPI != "cli") die("skip CLI only test");
if (!function_exists("dl")) die("skip need dl");
?>
--TEST--
Reflection::getClosureScopeClass()
---SKIPIF--
-<?php
-if (!extension_loaded('reflection')) print 'skip';
-?>
---FILE--
+--FILE--
<?php
$closure = function($param) { return "this is a closure"; };
$rf = new ReflectionFunction($closure);
$rf = new ReflectionFunction($closure);
var_dump($rf->getClosureScopeClass());
echo "Done!\n";
+?>
--EXPECTF--
NULL
object(ReflectionClass)#%d (1) {
--TEST--
Reflection::getClosureThis()
---SKIPIF--
-<?php
-if (!extension_loaded('reflection')) print 'skip';
-?>
---FILE--
+--FILE--
<?php
$closure = function($param) { return "this is a closure"; };
$rf = new ReflectionFunction($closure);
var_dump($rf->getClosureThis());
echo "Done!\n";
+?>
--EXPECTF--
NULL
Done!
--CREDITS--
Stefan Koopmanschap <stefan@phpgg.nl>
TestFest PHP|Tek
---SKIPIF--
-<?php
-if (!extension_loaded('reflection')) print 'skip';
-?>
---FILE--
+--FILE--
<?php
$closure = function($param) { return "this is a closure"; };
$rc = new ReflectionFunction($closure);
var_dump($rc->isClosure());
+?>
--EXPECTF--
bool(true)
--CREDITS--
Stefan Koopmanschap <stefan@phpgg.nl>
TestFest PHP|Tek
---SKIPIF--
-<?php
-if (!extension_loaded('reflection')) print 'skip';
-?>
--INI--
disable_functions=is_file
---FILE--
+--FILE--
<?php
$rc = new ReflectionFunction('is_file');
var_dump($rc->isDisabled());
+?>
--EXPECTF--
bool(true)
--TEST--
Reflection::getClosureThis()
---SKIPIF--
-<?php
-if (!extension_loaded('reflection')) print 'skip';
-?>
---FILE--
+--FILE--
<?php
class StaticExample
{
var_dump($rf->getClosureThis());
echo "Done!\n";
+?>
--EXPECTF--
NULL
object(Example)#%d (1) {
--TEST--
ReflectionMethod::getDocComment() uses left over doc comment from previous scanner run
+--SKIPIF--
+<?php if (!extension_loaded('tokenizer')) die('skip tokenizer extension not loaded'); ?>
--INI--
opcache.save_comments=1
---SKIPIF--
-<?php
-if (!extension_loaded('reflection') || !extension_loaded('tokenizer')) print 'skip missing reflection of tokernizer extension';
-?>
--FILE--
<?php