-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reflection: Fix the return value of ReflectionFunction::{getNamespace…
…Name,inNamespace}() for closures (#16129) * reflection: Fix the return value of ReflectionFunction::{getNamespaceName,inNamespace}() for closures Fixes GH-16122 * reflection: Clean up implementation of `ReflectionFunctionAbstract::inNamespace()` * reflection: Clean up implementation of `ReflectionFunctionAbstract::getNamespaceName()`
- Loading branch information
Showing
4 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
--TEST-- | ||
ReflectionFunction::getShortName() returns the short name for first class callables defined in namespaces. | ||
ReflectionFunction::get{Short,Namespace}Name() and inNamespace() return the correct data for first class callables defined in namespaces. | ||
--FILE-- | ||
<?php | ||
namespace Foo; | ||
|
||
function foo() { | ||
} | ||
$r = new \ReflectionFunction(foo(...)); | ||
$r2 = new \ReflectionFunction('Foo\\foo'); | ||
var_dump($r->getShortName()); | ||
var_dump($r->getNamespaceName()); | ||
var_dump($r->inNamespace()); | ||
var_dump($r->getNamespaceName() . ($r->inNamespace() ? '\\' : '') . $r->getShortName() === $r->getName()); | ||
|
||
var_dump($r->getShortName() === $r2->getShortName()); | ||
var_dump($r->getNamespaceName() === $r2->getNamespaceName()); | ||
var_dump($r->inNamespace() === $r2->inNamespace()); | ||
?> | ||
--EXPECT-- | ||
string(3) "foo" | ||
string(3) "Foo" | ||
bool(true) | ||
bool(true) | ||
bool(true) | ||
bool(true) | ||
bool(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters