diff --git a/src/Collector/Stream/FilesystemStreamCollector.php b/src/Collector/Stream/FilesystemStreamCollector.php index 0c567d86..699a5616 100644 --- a/src/Collector/Stream/FilesystemStreamCollector.php +++ b/src/Collector/Stream/FilesystemStreamCollector.php @@ -7,6 +7,8 @@ use Yiisoft\Yii\Debug\Collector\CollectorTrait; use Yiisoft\Yii\Debug\Collector\SummaryCollectorInterface; +use function count; + final class FilesystemStreamCollector implements SummaryCollectorInterface { use CollectorTrait; @@ -17,23 +19,25 @@ public function __construct( * Examples: * - '/' . preg_quote('yii-debug/src/Dumper', '/') . '/' * - '/ClosureExporter/' + * + * @var string[] */ private readonly array $ignoredPathPatterns = [], + /** + * @var string[] + */ private readonly array $ignoredClasses = [], ) { } /** - * @var array[] + * @psalm-var array> */ private array $operations = []; public function getCollected(): array { - if (!$this->isActive()) { - return []; - } - return array_map('array_values', $this->operations); + return $this->isActive() ? $this->operations : []; } public function startup(): void diff --git a/src/Collector/Stream/FilesystemStreamProxy.php b/src/Collector/Stream/FilesystemStreamProxy.php index 51a71a66..528c9321 100644 --- a/src/Collector/Stream/FilesystemStreamProxy.php +++ b/src/Collector/Stream/FilesystemStreamProxy.php @@ -25,8 +25,20 @@ final class FilesystemStreamProxy implements StreamWrapperInterface public bool $ignored = false; public static ?FilesystemStreamCollector $collector = null; + + /** + * @var string[] + */ public static array $ignoredPathPatterns = []; + + /** + * @var string[] + */ public static array $ignoredClasses = []; + + /** + * @psalm-var array + */ public array $operations = []; public function __construct() @@ -107,7 +119,7 @@ public function stream_read(int $count): string|false { if (!$this->ignored) { $this->operations['read'] = [ - 'path' => $this->decorated->filename, + 'path' => $this->decorated->filename ?? '', 'args' => [], ]; } @@ -158,7 +170,7 @@ public function dir_readdir(): false|string { if (!$this->ignored) { $this->operations['readdir'] = [ - 'path' => $this->decorated->filename, + 'path' => $this->decorated->filename ?? '', 'args' => [], ]; } @@ -239,7 +251,7 @@ public function stream_write(string $data): int { if (!$this->ignored) { $this->operations['write'] = [ - 'path' => $this->decorated->filename, + 'path' => $this->decorated->filename ?? '', 'args' => [], ]; }