Skip to content

Commit

Permalink
PhpStormStubsSourceStubber should choose the first function definitio…
Browse files Browse the repository at this point in the history
…n in stubs - PHP works the same way
  • Loading branch information
kukulich committed Nov 27, 2021
1 parent 7f53c23 commit e312a7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,13 @@ private function parseFile(string $filePath): void
$this->modifyFunctionParametersByPhpVersion($functionNode);
}

$this->functionNodes[strtolower($functionName)] = $functionNode;
$lowercaseFunctionName = strtolower($functionName);

if (array_key_exists($lowercaseFunctionName, $this->functionNodes)) {
continue;
}

$this->functionNodes[$lowercaseFunctionName] = $functionNode;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,6 @@ public function testInternalFunctions(string $functionName): void

$originalReflection = new CoreReflectionFunction($functionName);

// There are more versions in PHP
if (
in_array($functionName, [
'setcookie',
'setrawcookie',
'stream_context_set_option',
'strtr',
], true)
) {
return;
}

$stubbedReflectionParameters = $stubbedReflection->getParameters();

self::assertSame($originalReflection->getNumberOfParameters(), $stubbedReflection->getNumberOfParameters());
Expand Down

0 comments on commit e312a7b

Please sign in to comment.