Skip to content

Commit

Permalink
Fixed parsing of PhpStormStubsElementAvailable in PhpStormStubsSource…
Browse files Browse the repository at this point in the history
…Stubber

`to: '7.2'` means to PHP "7.2.99"
  • Loading branch information
kukulich committed Nov 23, 2021
1 parent a89d21d commit 6961a5d
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 6961a5d

Please sign in to comment.