-
Notifications
You must be signed in to change notification settings - Fork 136
Avoid repeated source parsing when trying to analyse docblock types #346
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
3b8f4d1
Introduced PHPBench with sample benchmark
dantleech 9749722
Use 10 iterations
dantleech 1108c88
Split benchmark into methods
dantleech c3940f0
Added phpbecnh to travis
dantleech 461c17f
First brutally simple prototype of an implementation of docblock retu…
Ocramius 3dd1bda
Simplfied `ReflectionFunctionAbstract#inNamespace()`
Ocramius c69a98e
Using inheritance rather than `instanceof` to decide which types are …
Ocramius 9876e5c
Splitting out a new class `NamespaceNodeToReflectionTypeContext`
Ocramius d017749
Aligning test case to the new API of `/FindReturnType`
Ocramius 293c25c
Testing aliased type resolution
Ocramius 60dcce9
Removed unused imports
Ocramius b370f02
Prototyping around: replacing all usages of the `ContextFactory` with…
Ocramius 52075e5
Fixing existing tests to support the new `NamespaceNodeToReflectionTy…
Ocramius b08f919
Covering aliased types in `FindPropertyType`
Ocramius ad25740
Covering aliased types in `FindParameterType`
Ocramius 031a655
Automated CS fixes
Ocramius 2785b7e
Basic testing around `NamespaceNodeToReflectionTypeContext`
Ocramius 3b25659
Empty name => empty namespace
Ocramius a6ecd63
Basic testing around `NamespaceNodeToReflectionTypeContext` and names…
Ocramius bfb5ffa
Testing complex scenario with type resolutions, imported constants an…
Ocramius b182de0
Handling grouped use statements and excluding constant/function imports
Ocramius 405cbea
Automatic CS fixes
Ocramius 9ab5967
Adding docblock inspection for parameters and properties to the bench…
Ocramius aa0e676
Moved phpbench installation to a manual `composer require` to be exec…
Ocramius b530754
Removing `array_map` and `array_filter` api from extremely sensible A…
Ocramius c54d5c0
Revert "Removing `array_map` and `array_filter` api from extremely se…
Ocramius 5257e60
Adding minor note about cryptic double-`array_merge([], ...foo)` call
Ocramius ff93dd1
Removing outdated TODO and comment
Ocramius 8ae8292
Documenting newly introduced BC Breakages
Ocramius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"bootstrap": "vendor/autoload.php", | ||
"path": "test/benchmark" | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
use PhpParser\Node; | ||
use PhpParser\Node\NullableType; | ||
use PhpParser\Node\Param as ParamNode; | ||
use PhpParser\Node\Stmt\Namespace_; | ||
use Reflector as CoreReflector; | ||
use Roave\BetterReflection\NodeCompiler\CompileNodeToValue; | ||
use Roave\BetterReflection\NodeCompiler\CompilerContext; | ||
|
@@ -32,6 +33,11 @@ class ReflectionParameter implements CoreReflector | |
*/ | ||
private $node; | ||
|
||
/** | ||
* @var Namespace_|null | ||
*/ | ||
private $declaringNamespace; | ||
|
||
/** | ||
* @var ReflectionFunctionAbstract | ||
*/ | ||
|
@@ -187,23 +193,28 @@ public function __toString() : string | |
} | ||
|
||
/** | ||
* @param Reflector $reflector | ||
* @param ParamNode $node Node has to be processed by the PhpParser\NodeVisitor\NameResolver | ||
* @param Reflector $reflector | ||
* @param ParamNode $node Node has to be processed by the PhpParser\NodeVisitor\NameResolver | ||
* @param Namespace_|null $declaringNamespace namespace of the declaring function/method | ||
* @param ReflectionFunctionAbstract $function | ||
* @param int $parameterIndex | ||
* @param int $parameterIndex | ||
* | ||
* @return ReflectionParameter | ||
*/ | ||
public static function createFromNode( | ||
Reflector $reflector, | ||
ParamNode $node, | ||
?Namespace_ $declaringNamespace, | ||
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. BC Break to be documented 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. Documented at 8ae8292 |
||
ReflectionFunctionAbstract $function, | ||
int $parameterIndex | ||
) : self { | ||
$param = new self(); | ||
$param->reflector = $reflector; | ||
$param->node = $node; | ||
$param->function = $function; | ||
$param->parameterIndex = $parameterIndex; | ||
$param = new self(); | ||
$param->reflector = $reflector; | ||
$param->node = $node; | ||
$param->declaringNamespace = $declaringNamespace; | ||
$param->function = $function; | ||
$param->parameterIndex = $parameterIndex; | ||
|
||
return $param; | ||
} | ||
|
||
|
@@ -402,7 +413,7 @@ public function getDocBlockTypeStrings() : array | |
*/ | ||
public function getDocBlockTypes() : array | ||
{ | ||
return (new FindParameterType())->__invoke($this->function, $this->node); | ||
return (new FindParameterType())->__invoke($this->function, $this->declaringNamespace, $this->node); | ||
} | ||
|
||
/** | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
BC Break to be documented
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.
Documented at 8ae8292