Skip to content

Commit

Permalink
Make functions present in functionMap but not in PhpStorm stubs known
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Mar 18, 2021
1 parent c1ca0c4 commit b51a26f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Reflection/Runtime/RuntimeReflectionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private function getCustomFunction(\PhpParser\Node\Name $nameNode, ?Scope $scope
public function resolveFunctionName(\PhpParser\Node\Name $nameNode, ?Scope $scope): ?string
{
return $this->resolveName($nameNode, function (string $name): bool {
$exists = function_exists($name);
$exists = function_exists($name) || $this->nativeFunctionReflectionProvider->findFunctionReflection($name) !== null;
if ($exists) {
if ($this->phpStormStubsSourceStubber->isPresentFunction($name) === false) {
return false;
Expand Down
6 changes: 6 additions & 0 deletions tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ public function testBug4288(): void
$this->assertSame(10, $nativeProperty->getDefaultValue());
}

public function testBug4702(): void
{
$errors = $this->runAnalyse(__DIR__ . '/data/bug-4702.php');
$this->assertCount(0, $errors);
}

/**
* @param string $file
* @return \PHPStan\Analyser\Error[]
Expand Down
6 changes: 6 additions & 0 deletions tests/PHPStan/Analyser/data/bug-4702.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

$archive = 'test.rar';
$password = '1323';

$archive = rar_open($archive, $password);

0 comments on commit b51a26f

Please sign in to comment.