Skip to content

Commit

Permalink
Merge pull request #875 from kukulich/phpstorm2
Browse files Browse the repository at this point in the history
Fixed parsing of `PhpStormStubsElementAvailable` in `PhpStormStubsSourceStubber` to comply with stubs declared PHP version
  • Loading branch information
Ocramius authored Nov 23, 2021
2 parents a89d21d + 6961a5d commit bba7bac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ private function getSupportedPhpVersions(

assert($attributeArg->value instanceof Node\Scalar\String_);

$toVersion = $this->parsePhpVersion($attributeArg->value->value);
$toVersion = $this->parsePhpVersion($attributeArg->value->value, 99);
}
}
}
Expand All @@ -516,11 +516,11 @@ private function getSupportedPhpVersions(
return [$fromVersion, $toVersion];
}

private function parsePhpVersion(string $version): int
private function parsePhpVersion(string $version, int $defaultPatch = 0): int
{
$parts = array_map('intval', explode('.', $version));

return $parts[0] * 10000 + $parts[1] * 100 + ($parts[2] ?? 0);
return $parts[0] * 10000 + $parts[1] * 100 + ($parts[2] ?? $defaultPatch);
}

private function getStubsDirectory(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ public function testFunctionInPhpVersion(string $functionName, ?int $phpVersion,

public function testFunctionWithDifferentParameterInPhpVersion74(): void
{
$sourceStubber = new PhpStormStubsSourceStubber($this->phpParser, 70400);
$sourceStubber = new PhpStormStubsSourceStubber($this->phpParser, 70499);
$phpInternalSourceLocator = new PhpInternalSourceLocator($this->astLocator, $sourceStubber);
$reflector = new DefaultReflector($phpInternalSourceLocator);

Expand Down

0 comments on commit bba7bac

Please sign in to comment.