-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add FS sniffing * Apply fixes from StyleCI * [ci-review] Apply changes from Rector action. * Fix return type * Add http(s) streams wrapper * Add test for FS stream * Fix types and stream wrapper logic * Refactor tests * Add a test for http stream * Rename collector * Add saving response for http client collector * Rewind bodies for request collector * Fix broken class names * Rewrite collecting events * Apply fixes from StyleCI * Fix psalm * Add composer-require-checker.json * Add TODO * Move comments to property description * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: rector-bot <[email protected]>
- Loading branch information
1 parent
dc6b167
commit f9a215b
Showing
30 changed files
with
1,298 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"symbol-whitelist": [ | ||
"opcache_invalidate" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Yii\Debug\Collector; | ||
|
||
final class FilesystemStreamCollector implements CollectorInterface, IndexCollectorInterface | ||
{ | ||
use CollectorTrait; | ||
|
||
public function __construct( | ||
/** | ||
* Collection of regexps to ignore files sources to sniff. | ||
* Examples: | ||
* - '/' . preg_quote('yii-debug/src/Dumper', '/') . '/' | ||
* - '/ClosureExporter/' | ||
*/ | ||
private array $ignoredPathPatterns = [], | ||
private array $ignoredClasses = [], | ||
) { | ||
} | ||
|
||
/** | ||
* @var array[] | ||
*/ | ||
private array $operations = []; | ||
|
||
public function getCollected(): array | ||
{ | ||
return array_map('array_values', $this->operations); | ||
} | ||
|
||
public function startup(): void | ||
{ | ||
$this->isActive = true; | ||
FilesystemStreamProxy::register(); | ||
FilesystemStreamProxy::$collector = $this; | ||
FilesystemStreamProxy::$ignoredPathPatterns = $this->ignoredPathPatterns; | ||
FilesystemStreamProxy::$ignoredClasses = $this->ignoredClasses; | ||
} | ||
|
||
public function shutdown(): void | ||
{ | ||
FilesystemStreamProxy::unregister(); | ||
FilesystemStreamProxy::$collector = null; | ||
FilesystemStreamProxy::$ignoredPathPatterns = []; | ||
FilesystemStreamProxy::$ignoredClasses = []; | ||
|
||
$this->reset(); | ||
$this->isActive = false; | ||
} | ||
|
||
public function collect(string $operation, string $path, array $args): void | ||
{ | ||
if (!$this->isActive()) { | ||
return; | ||
} | ||
|
||
$this->operations[$operation][] = [ | ||
'path' => $path, | ||
'args' => $args, | ||
]; | ||
} | ||
|
||
public function getIndexData(): array | ||
{ | ||
return [ | ||
'fs_stream' => array_merge( | ||
...array_map( | ||
fn (string $operation) => [$operation => count($this->operations[$operation])], | ||
array_keys($this->operations) | ||
) | ||
), | ||
]; | ||
} | ||
|
||
private function reset(): void | ||
{ | ||
$this->operations = []; | ||
} | ||
} |
Oops, something went wrong.