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:
Paul Tarjan
2013-05-16 03:00:28 -07:00
commit de Sara Golemon
commit a7c6ad1817
3 arquivos alterados com 72 adições e 0 exclusões
+45
Ver Arquivo
@@ -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);
}
}
///////////////////////////////////////////////////////////////////////////////
+19
Ver Arquivo
@@ -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());
?>
+8
Ver Arquivo
@@ -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"