Skip to content

Commit 31bbf12

Browse files
committed
chore(internal): update to psl 6, and fix typing/linting issues
Signed-off-by: azjezz <azjezz@protonmail.com>
1 parent 3f1458b commit 31bbf12

7 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "MIT",
55
"require": {
66
"php": "~8.5.0",
7-
"azjezz/psl": "^4.3.0"
7+
"php-standard-library/php-standard-library": "^6.1.0"
88
},
99
"autoload": {
1010
"psr-4": {

‎src/Application.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Psl\Iter;
1616
use Psl\Math;
1717
use Psl\Str;
18-
use Psl\Type;
1918
use Psl\Vec;
2019

2120
final class Application
@@ -81,7 +80,7 @@ private static function runBenchmark(string $rootDir, array $args): int
8180

8281
$benchmark = new Benchmark(
8382
tools: ToolPaths::resolve($rootDir, $phpBinary),
84-
runs: Type\positive_int()->assert($runs),
83+
runs: $runs,
8584
timeout: $timeout !== null ? Duration::minutes($timeout) : null,
8685
skipStability: $skipStability,
8786
filter: new BenchmarkFilter(kind: $filterKind, tool: $filterTool, project: $filterProject),

‎src/Benchmark/SystemStability.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ public static function check(int $maxCpu = 25, int $margin = 5, int $samples = 5
5959
}
6060
}
6161

62-
$min = Math\min($readings) ?? 0;
63-
$max = Math\max($readings) ?? 0;
62+
$min = Math\min($readings);
63+
$max = Math\max($readings);
6464
$spread = $max - $min;
6565

66-
$tooHigh = Math\max($readings) ?? 0;
66+
$tooHigh = Math\max($readings);
6767
if ($tooHigh > $maxCpu) {
6868
$spinner->fail(Str\format('CPU too high: %d%% (threshold: %d%%)', $tooHigh, $maxCpu));
6969
Output::error('Close other applications and try again.');

‎src/Profiler/Internal/MemoryProfiler.php‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* Uses proc_open to launch the command and polls RSS via {@see ProcessTreeRss}.
2323
* Falls back to `/usr/bin/time -l` for fast processes where polling misses the peak.
2424
*
25+
* @mago-expect lint:cyclomatic-complexity
26+
*
2527
* @internal
2628
*/
2729
final readonly class MemoryProfiler
@@ -80,13 +82,15 @@ private static function measureViaPolling(string $command, ?Duration $timeout):
8082

8183
/** @var array<int, resource> $pipes */
8284
$pipes = [];
83-
// @mago-expect analysis:possibly-invalid-argument
8485
$proc = proc_open(['sh', '-c', $command], $descriptors, $pipes, '/tmp');
8586
if ($proc === false) {
8687
return new ProfileFailure($command, -1, 'Failed to start process');
8788
}
8889

89-
fclose($pipes[0]);
90+
$stdin = $pipes[0] ?? null;
91+
if (null !== $stdin) {
92+
fclose($stdin);
93+
}
9094

9195
/** @var array{running: bool, pid: int, exitcode: int} $status */
9296
$status = proc_get_status($proc);

‎src/Profiler/Internal/PerformanceProfiler.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ private static function runOnce(string $command, ?Duration $timeout): ProfileFai
8282
$pipes = [];
8383
$before = Timestamp::monotonic();
8484

85-
// @mago-expect analysis:possibly-invalid-argument
8685
$proc = proc_open(['sh', '-c', $command], $descriptors, $pipes, '/tmp');
8786
if ($proc === false) {
8887
return new ProfileFailure($command, -1, 'Failed to start process');
8988
}
9089

91-
fclose($pipes[0]);
90+
$stdin = $pipes[0] ?? null;
91+
if ($stdin !== null) {
92+
fclose($stdin);
93+
}
9294

9395
/** @var array{running: bool, exitcode: int} $status */
9496
$status = proc_get_status($proc);

‎src/Site/ReportNormalizer.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private static function normalizeEntry(array $entry): ?array
6464
'max' => Type\float()->coerce($entry['max'] ?? 0.0),
6565
'memory_mb' => ($entry['memory_mb'] ?? null) !== null ? Type\float()->coerce($entry['memory_mb']) : null,
6666
'relative' => Type\float()->coerce($entry['relative'] ?? 1.0),
67-
'timed_out' => (bool) ($entry['timed_out'] ?? false),
67+
'timed_out' => (bool) ($entry['timed_out'] ?? false), // @mago-expect analysis:mixed-operand
6868
];
6969
}
7070
}

‎src/Support/TableRenderer.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ private static function formatRow(array $cells, array $colWidths, string $indent
7676
/** @var int<0, max> $i */
7777
$parts = Vec\map_with_key($colWidths, static function (int $i, int $w) use ($cells): string {
7878
$cell = $cells[$i] ?? '';
79-
/** @var int<0, max> $pad */
8079
$pad = Math\maxva(0, $w - self::displayWidth($cell));
8180

8281
return ' ' . $cell . Str\repeat(' ', $pad) . ' ';

0 commit comments

Comments
 (0)