<?php
// PHP 5.3 example
namespace aa {
?>
<html>
<head>
<style type="text/css">
body {font-size: 0.9em;}
</style>
<title>Advanced Reflection example</title>
</head>
<body>
<?php
date_default_timezone_set('Europe/Paris');
ini_set('display_errors', true);
error_reporting(E_ALL);
require("./reflection_php53.php");
function tester($aa) {
echo $aa;
}
abstract class GenericParent
{
public function __construct($name) {
echo $name;
}
}
class /* aaaa */ MyParent extends GenericParent
{
public function __construct($name) {
echo strtoupper($name);
}
}
interface Test
{
}
// get information about the class
$x = new \System\Reflection\AdvancedReflectionClass('aa\MyParent');
echo
"<strong>Class aa\MyParent is in file ".$x->getFileName().
" and starts at col: ".$x->getStartColumn().
", line: ".$x->getStartLine().
", filepos: ".$x->getStartPosition()."</strong><br />";
highlight_string('<?php '.PHP_EOL.$x->getDeclaration());
echo '<hr>';
// get information about the parent class
$x = new \System\Reflection\AdvancedReflectionClass('aa\MyParent');
$x = $x->getParentClass();
echo
"<strong>Class aa\GenericParent is in file ".$x->getFileName().
" and starts at col: ".$x->getStartColumn().
", line: ".$x->getStartLine().
", filepos: ".$x->getStartPosition()."</strong><br />";
highlight_string('<?php '.PHP_EOL.$x->getDeclaration());
echo '<hr>';
// get information about the interface
$x = new \System\Reflection\AdvancedReflectionClass('aa\Test');
echo
"<strong>Interface aa\Test is in file ".$x->getFileName().
" and starts at col: ".$x->getStartColumn().
", line: ".$x->getStartLine().
", filepos: ".$x->getStartPosition()."</strong><br />";
highlight_string('<?php '.PHP_EOL.$x->getDeclaration());
echo '<hr>';
// get information about the class method
$x = new \System\Reflection\AdvancedReflectionMethod('aa\MyParent', '__construct');
echo
"<strong>Method aa\MyParent\__construct() is in file ".$x->getFileName().
" and starts at col: ".$x->getStartColumn().
", line: ".$x->getStartLine().
", filepos: ".$x->getStartPosition()."</strong><br />";
highlight_string('<?php '.PHP_EOL.$x->getDeclaration());
echo '<hr>';
// get information about the function
$x = new \System\Reflection\AdvancedReflectionFunction('aa\tester');
echo
"<strong>Function tester() is in file ".$x->getFileName().
" and starts at col: ".$x->getStartColumn().
", line: ".$x->getStartLine().
", filepos: ".$x->getStartPosition()."</strong><br />";
highlight_string('<?php '.PHP_EOL.$x->getDeclaration());
?>
</body>
</html>
<?php
}
?>
|