-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility for ReflectionFunctionAbstract and ReflectionFunction #40
Changes from 12 commits
25dc7fb
4d8bc4b
62a27e0
4a31ae8
27e5751
07ff5e4
0116d92
82de5f8
da138a3
61ea1e5
a224087
67e5b04
0facb6f
9bf3a82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,20 @@ | |
|
||
use PhpParser\Node; | ||
use BetterReflection\Reflection\ReflectionClass; | ||
use BetterReflection\Reflection\ReflectionFunction; | ||
use BetterReflection\Reflection\Reflection; | ||
|
||
class IdentifierType | ||
{ | ||
const IDENTIFIER_CLASS = ReflectionClass::class; | ||
const IDENTIFIER_FUNCTION = ReflectionFunction::class; | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
private $validTypes = [ | ||
self::IDENTIFIER_CLASS, | ||
self::IDENTIFIER_FUNCTION, | ||
]; | ||
|
||
/** | ||
|
@@ -50,10 +53,12 @@ public function getName() | |
public function isMatchingReflector(Reflection $reflector) | ||
{ | ||
if ($this->name == self::IDENTIFIER_CLASS) { | ||
return $reflector instanceof ReflectionClass; | ||
return ($reflector instanceof ReflectionClass); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. constants? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. one day There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. one issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
// @todo add more type checks | ||
if ($this->name == self::IDENTIFIER_FUNCTION) { | ||
return ($reflector instanceof ReflectionFunction); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. parenthesis not needed |
||
} | ||
|
||
return false; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace BetterReflection\Reflection; | ||
|
||
use PhpParser\Node\Stmt\Function_ as FunctionNode; | ||
use PhpParser\Node\Stmt\Namespace_ as NamespaceNode; | ||
|
||
class ReflectionFunction extends ReflectionFunctionAbstract implements Reflection | ||
{ | ||
/** | ||
* @param FunctionNode $node | ||
* @param NamespaceNode|null $namespaceNode | ||
* @param string|null $filename | ||
* @return ReflectionMethod | ||
*/ | ||
public static function createFromNode( | ||
FunctionNode $node, | ||
NamespaceNode $namespaceNode = null, | ||
$filename = null | ||
) { | ||
$method = new self($node); | ||
|
||
$method->populateFunctionAbstract($node, $namespaceNode, $filename); | ||
|
||
return $method; | ||
} | ||
|
||
/** | ||
* Check to see if this function has been disabled (by the PHP INI file | ||
* directive `disable_functions`) | ||
* | ||
* Note - we cannot reflect on internal functions (as there is no PHP source | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Link #14 here |
||
* code we can access. This means, at present, we can only EVER return false | ||
* from this function, because you cannot disable user-defined functions. | ||
* | ||
* @see http://php.net/manual/en/ini.core.php#ini.disable-functions | ||
* @return bool | ||
*/ | ||
public function isDisabled() | ||
{ | ||
return false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parenthesis not needed