本文整理汇总了PHP中Reflection::export方法的典型用法代码示例。如果您正苦于以下问题:PHP Reflection::export方法的具体用法?PHP Reflection::export怎么用?PHP Reflection::export使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reflection
的用法示例。
在下文中一共展示了Reflection::export方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($class, $test_func)
{
// buffer output and collect it for later use.
$this->test_start($class);
$this->test_start("Reflection", true);
// create the reflector
$this->reflector = new ReflectionClass($class);
Reflection::export($this->reflector);
echo $this->test_end("Reflection");
// run test function
$this->test_set_success($class, $test_func($this, $this->reflector));
$this->buffer = $this->test_end($class);
//var_dump($this->tests);
//$this->buffer = $this->tests[$class]['buffer'];
}
示例2: serve
/**
* This method calls functions on the implementation class and returns the output or Fault object in case of error to client
*
* @return unknown
*/
function serve()
{
if (empty($_REQUEST['method']) || !method_exists($this->implementation, $_REQUEST['method'])) {
if (empty($_REQUEST['method'])) {
echo '<pre>';
Reflection::export(new ReflectionClass(get_class($this->implementation)));
} else {
$er = new SoapError();
$er->set_error('invalid_call');
$this->fault($er);
}
} else {
$method = $_REQUEST['method'];
return $this->implementation->{$method}();
}
// else
}
示例3: _update
function _update(KISS_DataObject $pKDO)
{
$keys = $pKDO->get_keys();
foreach ($keys['primary'] as $key => $value) {
$sub_sql[] = "{$value['column']}=:{$value['column']}";
}
$columns = $pKDO->get_columns();
foreach ($columns as $key => $value) {
$sub_sql1[] = "{$key}=:{$key}";
}
$sql = sprintf(self::SQL_UPDATE, 'student', implode(',', $sub_sql1), implode(' and ', $sub_sql));
$db = new PDO('mysql:host=127.0.0.1;dbname=test', 'web', 'develop');
$stmt = $db->prepare($sql);
foreach ($columns as $key => $value) {
$stmt->bindParam($key, $pKDO->{$key});
}
Reflection::export(new ReflectionObject($stmt));
//$stmt->execute();
}
示例4: test
<?php
class CdProduct
{
public $data;
public function test()
{
return true;
}
}
//
print_r(get_class_methods('CdProduct'));
//反射
$prod_class = new ReflectionClass('CdProduct');
Reflection::export($prod_class);
示例5: ReflectionClass
<?php
/**
* Created by PhpStorm.
* User: Nigel
* Date: 2016/1/14
* Time: 20:46
*/
use Nigel\NEU\AAO;
include "autoload.php";
Reflection::export(new ReflectionClass(new stdClass()));
示例6: ReflectionClass
<?php
class just_constants
{
const BOOLEAN_CONSTANT = true;
const NULL_CONSTANT = null;
const STRING_CONSTANT = 'This is a string';
const INTEGER_CONSTANT = 1000;
const FLOAT_CONSTANT = 3.14159265;
}
Reflection::export(new ReflectionClass('just_constants'));
示例7: classInfo
public static function classInfo($classname)
{
echo "<pre>";
Reflection::export(new ReflectionClass($classname));
echo "</pre>";
}
示例8: foo
<?php
function foo()
{
}
class bar
{
private function foo()
{
}
}
Reflection::export(new ReflectionFunction('foo'));
Reflection::export(new ReflectionMethod('bar', 'foo'));
?>
===DONE===
示例9: my_error_handler
<?php
function my_error_handler($errno, $errstr, $errfile, $errline)
{
echo "Error: {$errstr}\n";
}
set_error_handler('my_error_handler');
class Setting extends ReflectionObject
{
}
Reflection::export(simplexml_load_string('<test/>', 'Setting'));
Reflection::export(simplexml_load_file('data:,<test/>', 'Setting'));
?>
===DONE===
示例10: printf
printf("%s is %sabstract.<br />\n", $rc->getName(), $rc->isAbstract() ? '' : 'not ');
printf("%s is %sfinal.</p>\n", $rc->getName(), $rc->isFinal() ? '' : 'not ');
$constants = $rc->getConstants();
$num_constants = count($constants);
printf("%s defines %d constant%s", $rc->getName(), $num_constants == 0 ? 'no' : $num_constants, $num_constants != 1 ? 's' : '');
if ($num_constants > 0) {
printf(":<pre>%s</pre>", print_r($constants, TRUE));
}
$props = $rc->getProperties();
$num_props = count($props);
printf("%s defines %d propert%s", $rc->getName(), $num_props == 0 ? 'no' : $num_props, $num_props == 1 ? 'y' : 'ies');
if ($num_props > 0) {
print ':';
foreach ($props as $prop) {
print "<pre>";
Reflection::export($prop);
print "</pre>";
}
}
$methods = $rc->getMethods();
$num_methods = count($methods);
printf("%s defines %d method%s<br />\n", $rc->getName(), $num_methods == 0 ? 'no' : $num_methods, $num_methods != 1 ? 's' : '');
if ($num_methods > 0) {
print '<p>';
foreach ($methods as $method) {
printf("%s%s%s%s%s%s() ", $method->isFinal() ? 'final ' : '', $method->isAbstract() ? 'abstract ' : '', $method->isPublic() ? 'public ' : '', $method->isPrivate() ? 'private ' : '', $method->isProtected() ? 'protected ' : '', $method->getName());
$params = $method->getParameters();
$num_params = count($params);
printf("has %s parameter%s%s", $num_params == 0 ? 'no' : $num_params, $num_params != 1 ? 's' : '', $num_params > 0 ? ': ' : '');
if ($num_params > 0) {
$names = array();
示例11: sayHello
<pre>
<?php
function sayHello($name, $h)
{
static $count = 0;
return "<h{$h}>Hello, {$name}</h{$h}>";
}
// Обзор функции
Reflection::export(new ReflectionFunction('sayHello'));
// Создание экземпляра класса ReflectionFunction
$func = new ReflectionFunction('sayHello');
// Вывод основной информации
printf("<p>===> %s функция '%s'\n" . " объявлена в %s\n" . " строки с %d по %d\n", $func->isInternal() ? 'Internal' : 'User-defined', $func->getName(), $func->getFileName(), $func->getStartLine(), $func->getEndline());
// Вывод статических переменных, если они есть
if ($statics = $func->getStaticVariables()) {
printf("<p>---> Статическая переменная: %s\n", var_export($statics, 1));
}
// Вызов функции
printf("<p>---> Результат вызова: ");
$result = $func->invoke("John", "1");
echo $result;
?>
</pre>
示例12: ReflectionFunction
<?php
Reflection::export(new ReflectionFunction('htmlspecialchars'));
Reflection::export(new ReflectionFunction('get_html_translation_table'));
示例13: __construct
/**
* My constructor
* @param string $name
*/
public function __construct($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
public function setSpouse(Person $spouse)
{
$this->spouse = $spouse;
}
private function setPassword($password)
{
$this->password = $password;
}
}
$reflectionClass = new ReflectionClass('Person');
echo Reflection::export($reflectionClass, true);
$firstMethod = $reflectionClass->getMethods()[0];
$firstProperty = $reflectionClass->getProperties()[0];
var_dump($reflectionClass->getMethods(), $reflectionClass->hasMethod('getName'), $firstMethod->getDocComment(), $firstMethod->getParameters(), $reflectionClass->getProperties(), $firstProperty->isPublic());
echo '<hr />';
ReflectionObject::export(new Person('Reflection'));
?>
</pre>
示例14: foo
<pre>
<?php
abstract class MyClass
{
public $a = 1;
protected $b = 2;
private $c = 3;
public static $cnt = 0;
const HANDS = 2;
abstract function foo();
public static function bar()
{
//Что-то делаем
}
public function sayHello($name, $h = "1")
{
static $count = 0;
return "<h{$h}>Hello, {$name}</h{$h}>";
}
}
// Обзор пользовательского класса
Reflection::export(new ReflectionClass('MyClass'));
exit;
// Обзор встроенного класса
Reflection::export(new ReflectionClass('Exception'));
?>
</pre>
示例15: reflectionClass
/**
* Возвращает структуру класса
*
* @param string $var
*
* @return string
*/
protected function reflectionClass($var)
{
$classInfo = new \ReflectionClass($var);
return \Reflection::export($classInfo, true);
}