Skip to content
Open
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
12 changes: 0 additions & 12 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ parameters:
count: 2
path: src/Command/CommandHelper.php

-
rawMessage: 'Parameter #1 $path of function dirname expects string, string|false given.'
identifier: argument.type
count: 1
path: src/Command/CommandHelper.php

-
rawMessage: 'Static property PHPStan\Command\CommandHelper::$reservedMemory is never read, only written.'
identifier: property.onlyWritten
Expand Down Expand Up @@ -240,12 +234,6 @@ parameters:
count: 1
path: src/DependencyInjection/NeonAdapter.php

-
rawMessage: 'Parameter #1 $path of function dirname expects string, string|false given.'
identifier: argument.type
count: 1
path: src/Diagnose/PHPStanDiagnoseExtension.php

-
rawMessage: 'Call to method getContent() of internal class PhpMerge\internal\Line from outside its root namespace PhpMerge.'
identifier: method.internalClass
Expand Down
6 changes: 5 additions & 1 deletion src/Command/CommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ public static function begin(

if (class_exists('PHPStan\ExtensionInstaller\GeneratedConfig')) {
$generatedConfigReflection = new ReflectionClass('PHPStan\ExtensionInstaller\GeneratedConfig');
$generatedConfigDirectory = dirname($generatedConfigReflection->getFileName());
$generatedConfigFileName = $generatedConfigReflection->getFileName();
if ($generatedConfigFileName === false) {
throw new ShouldNotHappenException('PHPStan\ExtensionInstaller\GeneratedConfig is not defined in a file.');
}
$generatedConfigDirectory = dirname($generatedConfigFileName);
foreach (GeneratedConfig::EXTENSIONS as $name => $extensionConfig) {
foreach ($extensionConfig['extra']['includes'] ?? [] as $includedFile) {
if (!is_string($includedFile)) {
Expand Down
7 changes: 6 additions & 1 deletion src/Diagnose/PHPStanDiagnoseExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PHPStan\Internal\ComposerHelper;
use PHPStan\Php\ComposerPhpVersionFactory;
use PHPStan\Php\PhpVersion;
use PHPStan\ShouldNotHappenException;
use ReflectionClass;
use function array_count_values;
use function array_key_exists;
Expand Down Expand Up @@ -133,7 +134,11 @@ public function print(Output $output, array $processedFiles): void
}

$generatedConfigReflection = new ReflectionClass('PHPStan\ExtensionInstaller\GeneratedConfig');
$generatedConfigDirectory = dirname($generatedConfigReflection->getFileName());
$generatedConfigFileName = $generatedConfigReflection->getFileName();
if ($generatedConfigFileName === false) {
throw new ShouldNotHappenException('PHPStan\ExtensionInstaller\GeneratedConfig is not defined in a file.');
}
$generatedConfigDirectory = dirname($generatedConfigFileName);
foreach (GeneratedConfig::EXTENSIONS as $name => $extensionConfig) {
$output->writeLineFormatted(sprintf('%s: %s', $name, $extensionConfig['version'] ?? 'Unknown version'));
foreach ($extensionConfig['extra']['includes'] ?? [] as $includedFile) {
Expand Down
8 changes: 7 additions & 1 deletion src/Testing/TestCaseSourceLocatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use function dirname;
use function hash;
use function is_file;
use function is_string;
use function serialize;
use const PHP_VERSION_ID;

Expand Down Expand Up @@ -72,7 +73,12 @@ public function create(): SourceLocator
$vendorDirProperty->setAccessible(true);
}
foreach ($classLoaders as $classLoader) {
$composerProjectPath = dirname($vendorDirProperty->getValue($classLoader));
$vendorDir = $vendorDirProperty->getValue($classLoader);
if (!is_string($vendorDir)) {
continue;
}

$composerProjectPath = dirname($vendorDir);
if (!is_file($composerProjectPath . '/composer.json')) {
continue;
}
Expand Down
Loading