Skip to content

Commit

Permalink
Fix incosistent names
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Nov 5, 2021
1 parent 151421c commit 9f2b6eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Reflection/ReflectionMethod.php
Expand Up @@ -292,7 +292,7 @@ public function getReturnType() : ?ReflectionType
public function hasTentativeReturnType(): bool
{
foreach ($this->getAttributes() as $attribute) {
if ($attribute->getName() === 'TentativeType' || $attribute->getName() === 'JetBrains\PhpStorm\Internal\TentativeType') {
if ($attribute->getName() === 'JetBrains\PhpStorm\Internal\TentativeType') {
return true;
}
}
Expand Down
19 changes: 11 additions & 8 deletions src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php
Expand Up @@ -63,8 +63,8 @@ final class PhpStormStubsSourceStubber implements SourceStubber
/** @var Standard */
private $prettyPrinter;

/** @var NodeTraverser */
private $nodeTraverser;
/** @var NameResolver */
private $nameResolver;

/** @var string|null */
private $stubsDirectory;
Expand Down Expand Up @@ -101,11 +101,9 @@ public function __construct(Parser $phpParser, ?int $phpVersionId = null)
$this->builderFactory = new BuilderFactory();
$this->prettyPrinter = new Standard(self::BUILDER_OPTIONS);

$this->cachingVisitor = $this->createCachingVisitor();
$this->nameResolver = new NameResolver();

$this->nodeTraverser = new NodeTraverser();
$this->nodeTraverser->addVisitor(new NameResolver());
$this->nodeTraverser->addVisitor($this->cachingVisitor);
$this->cachingVisitor = $this->createCachingVisitor();

$this->classMap = array_change_key_case(PhpStormStubsMap::CLASSES);
$this->functionMap = array_change_key_case(PhpStormStubsMap::FUNCTIONS);
Expand Down Expand Up @@ -320,11 +318,16 @@ private function parseFile(string $filePath) : void
$isCore = $this->isCoreExtension($this->getExtensionFromFilePath($filePath));

$ast = $this->phpParser->parse(file_get_contents($absoluteFilePath));
$nodeTraverser = new NodeTraverser();
$nodeTraverser->addVisitor($this->nameResolver);
$nodeTraverser->traverse($ast);

/** @psalm-suppress UndefinedMethod */
$this->cachingVisitor->clearNodes();

$this->nodeTraverser->traverse($ast);
$nodeTraverser = new NodeTraverser();
$nodeTraverser->addVisitor($this->cachingVisitor);
$nodeTraverser->traverse($ast);

/**
* @psalm-suppress UndefinedMethod
Expand Down Expand Up @@ -419,7 +422,7 @@ private function hasLaterSinceVersion(Node $node) : bool
foreach ($node->attrGroups as $attrGroup) {
foreach ($attrGroup->attrs as $attr) {
$name = $attr->name->toLowerString();
if ($name !== 'phpstormstubselementavailable' && $name !== 'jetbrains\\phpstorm\\internal\\phpstormstubselementavailable') {
if ($name !== 'jetbrains\\phpstorm\\internal\\phpstormstubselementavailable') {
continue;
}

Expand Down

0 comments on commit 9f2b6eb

Please sign in to comment.