add namespace reflection methods
added in 5.3 I couldn't actually get the ##sysdoc.php## to work (it just deleted all the docblocks), so I just copied the format.
Esse commit está contido em:
@@ -1492,6 +1492,51 @@ class ReflectionClass implements Reflector {
|
||||
public function getAttributesRecursive() {
|
||||
return $this->fetch('attributes_rec');
|
||||
}
|
||||
|
||||
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
|
||||
/**
|
||||
* ( excerpt from http://www.php.net/manual/en/reflectionclass.innamespace.php )
|
||||
*
|
||||
* Checks if in namespace
|
||||
*
|
||||
* @return bool Returns TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function inNamespace() {
|
||||
return strrpos($this->getName(), '\\') !== false;
|
||||
}
|
||||
|
||||
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
|
||||
/**
|
||||
* ( excerpt from http://php.net/manual/en/reflectionclass.getnamespacename.php )
|
||||
*
|
||||
* Gets namespace name
|
||||
*
|
||||
* @return string The namespace name.
|
||||
*/
|
||||
public function getNamespaceName() {
|
||||
$pos = strrpos($this->getName(), '\\');
|
||||
if ($pos === false) {
|
||||
return '';
|
||||
}
|
||||
return substr($this->getName(), 0, $pos);
|
||||
}
|
||||
|
||||
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
|
||||
/**
|
||||
* ( excerpt from http://www.php.net/manual/en/reflectionclass.getshortname.php )
|
||||
*
|
||||
* Gets short name
|
||||
*
|
||||
* @return string The class short name.
|
||||
*/
|
||||
public function getShortName() {
|
||||
$pos = strrpos($this->getName(), '\\');
|
||||
if ($pos === false) {
|
||||
return $this->getName();
|
||||
}
|
||||
return substr($this->getName(), $pos + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace A\B;
|
||||
|
||||
class Foo { }
|
||||
|
||||
$function = new \ReflectionClass('stdClass');
|
||||
|
||||
var_dump($function->inNamespace());
|
||||
var_dump($function->getName());
|
||||
var_dump($function->getNamespaceName());
|
||||
var_dump($function->getShortName());
|
||||
|
||||
$function = new \ReflectionClass('A\\B\\Foo');
|
||||
|
||||
var_dump($function->inNamespace());
|
||||
var_dump($function->getName());
|
||||
var_dump($function->getNamespaceName());
|
||||
var_dump($function->getShortName());
|
||||
?>
|
||||
@@ -0,0 +1,8 @@
|
||||
bool(false)
|
||||
string(8) "stdClass"
|
||||
string(0) ""
|
||||
string(8) "stdClass"
|
||||
bool(true)
|
||||
string(7) "A\B\Foo"
|
||||
string(3) "A\B"
|
||||
string(3) "Foo"
|
||||
Referência em uma Nova Issue
Bloquear um usuário