Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function __construct(private SignatureMapProvider $signatureMapProvider,
public function findFunctionReflection(string $functionName): ?NativeFunctionReflection
{
$lowerCasedFunctionName = strtolower($functionName);
$realFunctionName = $lowerCasedFunctionName;
if (isset($this->functionMap[$lowerCasedFunctionName])) {
return $this->functionMap[$lowerCasedFunctionName];
}
Expand All @@ -54,6 +55,7 @@ public function findFunctionReflection(string $functionName): ?NativeFunctionRef
$reflectionFunction = $this->reflector->reflectFunction($functionName);
$reflectionFunctionAdapter = new ReflectionFunction($reflectionFunction);
$returnsByReference = TrinaryLogic::createFromBoolean($reflectionFunctionAdapter->returnsReference());
$realFunctionName = $reflectionFunction->getName();
if ($reflectionFunction->getFileName() !== null) {
$fileName = $reflectionFunction->getFileName();
$docComment = $reflectionFunction->getDocComment();
Expand Down Expand Up @@ -127,7 +129,7 @@ public function findFunctionReflection(string $functionName): ?NativeFunctionRef
}

$functionReflection = new NativeFunctionReflection(
$lowerCasedFunctionName,
$realFunctionName,
$variants,
$throwType,
$hasSideEffects,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,18 @@ public function testBug8205(): void
$this->analyse([__DIR__ . '/data/bug-8205.php'], []);
}

public function testBug10003(): void
{
$this->analyse([__DIR__ . '/data/bug-10003.php'], [
[
'Call to function MongoDB\Driver\Monitoring\addSubscriber() with incorrect case: MONGODB\Driver\Monitoring\addSubscriber',
10,
],
[
'Call to function MongoDB\Driver\Monitoring\addSubscriber() with incorrect case: mongodb\driver\monitoring\addsubscriber',
14,
],
]);
}

}
16 changes: 16 additions & 0 deletions tests/PHPStan/Rules/Functions/data/bug-10003.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php declare(strict_types = 1);

namespace Bug10003;

class HelloWorld
{
public function check(\MongoDB\Driver\Monitoring\Subscriber $a): void
{
// Wrong.
\MONGODB\Driver\Monitoring\addSubscriber($a);
// Correct.
\MongoDB\Driver\Monitoring\addSubscriber($a);
// Wrong.
\mongodb\driver\monitoring\addsubscriber($a);
}
}