/dev/null', escapeshellarg(PHP_BINARY), escapeshellarg($projectRoot.'/vendor/bin/phpstan'), escapeshellarg(__DIR__.'/integration.neon'), ); exec($command, $output, $exitCode); self::assertSame(1, $exitCode, 'phpstan should report errors for the fixture'); // Local tooling may prefix phpstan's stdout with guidance text; the // JSON report starts at the first brace. $raw = implode('', $output); $braceOffset = strpos($raw, '{'); self::assertIsInt($braceOffset, 'no JSON object found in phpstan output'); $report = json_decode(substr($raw, $braceOffset), true, 32, JSON_THROW_ON_ERROR); self::assertIsArray($report); $messages = []; foreach ($report['files'] as $file) { foreach ($file['messages'] as $message) { $messages[] = [$message['identifier'] ?? '?', $message['line']]; } } $count = static fn (string $identifier): int => count( array_filter($messages, static fn (array $entry): bool => $entry[0] === $identifier), ); // Dynamic property/brace/method names: symplify NoDynamicNameRule. self::assertSame(3, $count('symplify.noDynamicName'), var_export($messages, true)); // The dynamic static-property form comes from phpstan-strict-rules' // *.dynamicName family, which also doubles the instance forms. $dynamicNameFamily = count(array_filter( $messages, static fn (array $entry): bool => str_ends_with($entry[0], '.dynamicName'), )); self::assertSame(4, $dynamicNameFamily, var_export($messages, true)); // call_user_func / call_user_func_array / ReflectionProperty::getValue: spaze. self::assertSame(3, $count('rules.noDynamicAccess'), var_export($messages, true)); // is_string / is_numeric outside a boundary path: spaze. self::assertSame(2, $count('rules.noRuntimeTypeChecks'), var_export($messages, true)); } }