Skip to content

Commit

Permalink
14
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Dec 19, 2024
1 parent 8d3dd49 commit b4cdf7f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
14 changes: 9 additions & 5 deletions src/Collector/Stream/FilesystemStreamCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<string, list<array{path: string, args: 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
Expand Down
18 changes: 15 additions & 3 deletions src/Collector/Stream/FilesystemStreamProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, array{path: string, args: array}>
*/
public array $operations = [];

public function __construct()
Expand Down Expand Up @@ -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' => [],
];
}
Expand Down Expand Up @@ -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' => [],
];
}
Expand Down Expand Up @@ -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' => [],
];
}
Expand Down

0 comments on commit b4cdf7f

Please sign in to comment.