Skip to content

Commit

Permalink
PhpStanNamespaceIn3rdPartyPackageRule - fix segfault when there's no …
Browse files Browse the repository at this point in the history
…composer.json
  • Loading branch information
ondrejmirtes committed Nov 2, 2021
1 parent ccff300 commit d4efedb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Rules/Api/PhpStanNamespaceIn3rdPartyPackageRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ private function findComposerJsonContents(string $fromDirectory): ?array

$composerJsonPath = $fromDirectory . '/composer.json';
if (!is_file($composerJsonPath)) {
return $this->findComposerJsonContents(dirname($fromDirectory));
$dirName = dirname($fromDirectory);
if ($dirName !== $fromDirectory) {
return $this->findComposerJsonContents($dirName);
}

return null;
}

try {
Expand Down

0 comments on commit d4efedb

Please sign in to comment.