From 1738980c6b8c94cd83c0910ae4bf4ad6f9970791 Mon Sep 17 00:00:00 2001 From: TomatoPana <22053906+TomatoPana@users.noreply.github.com> Date: Sun, 7 Dec 2025 19:05:44 -0600 Subject: [PATCH 1/7] feat: Bumping supported php Version and adjusted dependencies to install with PHP 8.5 --- composer.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index ba0aa9c0..091a96e0 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,9 @@ { "name": "laravel/pulse", "description": "Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.", - "keywords": ["laravel"], + "keywords": [ + "laravel" + ], "homepage": "https://github.com/laravel/pulse", "license": "MIT", "support": { @@ -15,7 +17,7 @@ } ], "require": { - "php": "^8.1", + "php": "^8.2", "guzzlehttp/promises": "^1.0|^2.0", "doctrine/sql-formatter": "^1.4.1", "illuminate/auth": "^10.48.4|^11.0.8|^12.0", @@ -40,7 +42,7 @@ "mockery/mockery": "^1.0", "orchestra/testbench": "^8.36|^9.15|^10.8", "pestphp/pest": "^2.0|^3.0|^4.0", - "pestphp/pest-plugin-laravel": "^2.2", + "pestphp/pest-plugin-laravel": "^2.2|^3.0|^4.0", "phpstan/phpstan": "^1.12.21", "predis/predis": "^1.0|^2.0" }, @@ -96,4 +98,4 @@ "@php vendor/bin/pest" ] } -} +} \ No newline at end of file From 4e4bd846e5eee0c07d7f0dbba016d1799d53075c Mon Sep 17 00:00:00 2001 From: TomatoPana <22053906+TomatoPana@users.noreply.github.com> Date: Sun, 7 Dec 2025 19:16:12 -0600 Subject: [PATCH 2/7] feat: replace deprecated backtick operators with `shell_exec` functions --- src/Recorders/Servers.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Recorders/Servers.php b/src/Recorders/Servers.php index d97da1ad..8264a09e 100644 --- a/src/Recorders/Servers.php +++ b/src/Recorders/Servers.php @@ -72,7 +72,7 @@ public static function detectMemoryUsing(?callable $callback): void public function record(SharedBeat $event): void { $this->throttle(15, $event, function ($event) { - $server = $this->config->get('pulse.recorders.'.self::class.'.server_name'); + $server = $this->config->get('pulse.recorders.' . self::class . '.server_name'); $slug = Str::slug($server); ['total' => $memoryTotal, 'used' => $memoryUsed] = $this->memory(); @@ -85,9 +85,9 @@ public function record(SharedBeat $event): void 'cpu' => $cpu, 'memory_used' => $memoryUsed, 'memory_total' => $memoryTotal, - 'storage' => collect($this->config->get('pulse.recorders.'.self::class.'.directories')) // @phpstan-ignore argument.templateType, argument.templateType - ->filter(fn (string $directory) => ($this->pulse->rescue(fn () => disk_total_space($directory)) ?? false) !== false) - ->map(fn (string $directory) => [ + 'storage' => collect($this->config->get('pulse.recorders.' . self::class . '.directories')) // @phpstan-ignore argument.templateType, argument.templateType + ->filter(fn(string $directory) => ($this->pulse->rescue(fn() => disk_total_space($directory)) ?? false) !== false) + ->map(fn(string $directory) => [ 'directory' => $directory, 'total' => $total = intval(round(disk_total_space($directory) / 1024 / 1024)), // MB 'used' => intval(round($total - (disk_free_space($directory) / 1024 / 1024))), // MB @@ -107,11 +107,11 @@ protected function cpu(): int } return match (PHP_OS_FAMILY) { - 'Darwin' => (int) `top -l 1 | grep -E "^CPU" | tail -1 | awk '{ print $3 + $5 }'`, - 'Linux' => (int) `top -bn1 | grep -E '^(%Cpu|CPU)' | awk '{ print $2 + $4 }'`, - 'Windows' => (int) trim(`wmic cpu get loadpercentage | more +1`), - 'BSD' => (int) `top -b -d 2| grep 'CPU: ' | tail -1 | awk '{print$10}' | grep -Eo '[0-9]+\.[0-9]+' | awk '{ print 100 - $1 }'`, - default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), + 'Darwin' => (int) shell_exec("top -l 1 | grep -E \"^CPU\" | tail -1 | awk '{ print $3 + $5 }'"), + 'Linux' => (int) shell_exec("top -bn1 | grep -E '^(%Cpu|CPU)' | awk '{ print $2 + $4 }'"), + 'Windows' => (int) trim(shell_exec("wmic cpu get loadpercentage | more +1")), + 'BSD' => (int) shell_exec("top -b -d 2| grep 'CPU: ' | tail -1 | awk '{print$10}' | grep -Eo '[0-9]+\.[0-9]+' | awk '{ print 100 - $1 }'"), + default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), }; } @@ -127,19 +127,19 @@ protected function memory(): array } $memoryTotal = match (PHP_OS_FAMILY) { - 'Darwin' => intval(`sysctl hw.memsize | grep -Eo '[0-9]+'` / 1024 / 1024), - 'Linux' => intval(`cat /proc/meminfo | grep MemTotal | grep -E -o '[0-9]+'` / 1024), - 'Windows' => intval(((int) trim(`wmic ComputerSystem get TotalPhysicalMemory | more +1`)) / 1024 / 1024), - 'BSD' => intval(`sysctl hw.physmem | grep -Eo '[0-9]+'` / 1024 / 1024), - default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), + 'Darwin' => intval(shell_exec("sysctl hw.memsize | grep -Eo '[0-9]+'") / 1024 / 1024), + 'Linux' => intval(shell_exec("cat /proc/meminfo | grep MemTotal | grep -E -o '[0-9]+'") / 1024), + 'Windows' => intval(((int) trim(shell_exec("wmic ComputerSystem get TotalPhysicalMemory | more +1"))) / 1024 / 1024), + 'BSD' => intval(shell_exec("sysctl hw.physmem | grep -Eo '[0-9]+'") / 1024 / 1024), + default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), }; $memoryUsed = match (PHP_OS_FAMILY) { - 'Darwin' => $memoryTotal - intval(intval(`vm_stat | grep 'Pages free' | grep -Eo '[0-9]+'`) * intval(`pagesize`) / 1024 / 1024), // MB - 'Linux' => $memoryTotal - intval(`cat /proc/meminfo | grep MemAvailable | grep -E -o '[0-9]+'` / 1024), // MB - 'Windows' => $memoryTotal - intval(((int) trim(`wmic OS get FreePhysicalMemory | more +1`)) / 1024), // MB - 'BSD' => intval(intval(`( sysctl vm.stats.vm.v_cache_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_inactive_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_active_count | grep -Eo '[0-9]+' ) | awk '{s+=$1} END {print s}'`) * intval(`pagesize`) / 1024 / 1024), // MB - default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), + 'Darwin' => $memoryTotal - intval(intval(shell_exec("vm_stat | grep 'Pages free' | grep -Eo '[0-9]+'")) * intval(shell_exec("pagesize")) / 1024 / 1024), // MB + 'Linux' => $memoryTotal - intval(shell_exec("cat /proc/meminfo | grep MemAvailable | grep -E -o '[0-9]+'") / 1024), // MB + 'Windows' => $memoryTotal - intval(((int) trim(shell_exec("wmic OS get FreePhysicalMemory | more +1"))) / 1024), // MB + 'BSD' => intval(intval(shell_exec("( sysctl vm.stats.vm.v_cache_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_inactive_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_active_count | grep -Eo '[0-9]+' ) | awk '{s+=$1} END {print s}'")) * intval(shell_exec("pagesize")) / 1024 / 1024), // MB + default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), }; return [ From bc0aa03e41e6793c4b96947c4cfc1114ae2b63f9 Mon Sep 17 00:00:00 2001 From: TomatoPana <22053906+TomatoPana@users.noreply.github.com> Date: Mon, 8 Dec 2025 01:16:41 +0000 Subject: [PATCH 3/7] Fix code styling --- src/Recorders/Servers.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Recorders/Servers.php b/src/Recorders/Servers.php index 8264a09e..b05af49b 100644 --- a/src/Recorders/Servers.php +++ b/src/Recorders/Servers.php @@ -72,7 +72,7 @@ public static function detectMemoryUsing(?callable $callback): void public function record(SharedBeat $event): void { $this->throttle(15, $event, function ($event) { - $server = $this->config->get('pulse.recorders.' . self::class . '.server_name'); + $server = $this->config->get('pulse.recorders.'.self::class.'.server_name'); $slug = Str::slug($server); ['total' => $memoryTotal, 'used' => $memoryUsed] = $this->memory(); @@ -85,9 +85,9 @@ public function record(SharedBeat $event): void 'cpu' => $cpu, 'memory_used' => $memoryUsed, 'memory_total' => $memoryTotal, - 'storage' => collect($this->config->get('pulse.recorders.' . self::class . '.directories')) // @phpstan-ignore argument.templateType, argument.templateType - ->filter(fn(string $directory) => ($this->pulse->rescue(fn() => disk_total_space($directory)) ?? false) !== false) - ->map(fn(string $directory) => [ + 'storage' => collect($this->config->get('pulse.recorders.'.self::class.'.directories')) // @phpstan-ignore argument.templateType, argument.templateType + ->filter(fn (string $directory) => ($this->pulse->rescue(fn () => disk_total_space($directory)) ?? false) !== false) + ->map(fn (string $directory) => [ 'directory' => $directory, 'total' => $total = intval(round(disk_total_space($directory) / 1024 / 1024)), // MB 'used' => intval(round($total - (disk_free_space($directory) / 1024 / 1024))), // MB @@ -109,9 +109,9 @@ protected function cpu(): int return match (PHP_OS_FAMILY) { 'Darwin' => (int) shell_exec("top -l 1 | grep -E \"^CPU\" | tail -1 | awk '{ print $3 + $5 }'"), 'Linux' => (int) shell_exec("top -bn1 | grep -E '^(%Cpu|CPU)' | awk '{ print $2 + $4 }'"), - 'Windows' => (int) trim(shell_exec("wmic cpu get loadpercentage | more +1")), + 'Windows' => (int) trim(shell_exec('wmic cpu get loadpercentage | more +1')), 'BSD' => (int) shell_exec("top -b -d 2| grep 'CPU: ' | tail -1 | awk '{print$10}' | grep -Eo '[0-9]+\.[0-9]+' | awk '{ print 100 - $1 }'"), - default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), + default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), }; } @@ -129,17 +129,17 @@ protected function memory(): array $memoryTotal = match (PHP_OS_FAMILY) { 'Darwin' => intval(shell_exec("sysctl hw.memsize | grep -Eo '[0-9]+'") / 1024 / 1024), 'Linux' => intval(shell_exec("cat /proc/meminfo | grep MemTotal | grep -E -o '[0-9]+'") / 1024), - 'Windows' => intval(((int) trim(shell_exec("wmic ComputerSystem get TotalPhysicalMemory | more +1"))) / 1024 / 1024), + 'Windows' => intval(((int) trim(shell_exec('wmic ComputerSystem get TotalPhysicalMemory | more +1'))) / 1024 / 1024), 'BSD' => intval(shell_exec("sysctl hw.physmem | grep -Eo '[0-9]+'") / 1024 / 1024), - default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), + default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), }; $memoryUsed = match (PHP_OS_FAMILY) { - 'Darwin' => $memoryTotal - intval(intval(shell_exec("vm_stat | grep 'Pages free' | grep -Eo '[0-9]+'")) * intval(shell_exec("pagesize")) / 1024 / 1024), // MB + 'Darwin' => $memoryTotal - intval(intval(shell_exec("vm_stat | grep 'Pages free' | grep -Eo '[0-9]+'")) * intval(shell_exec('pagesize')) / 1024 / 1024), // MB 'Linux' => $memoryTotal - intval(shell_exec("cat /proc/meminfo | grep MemAvailable | grep -E -o '[0-9]+'") / 1024), // MB - 'Windows' => $memoryTotal - intval(((int) trim(shell_exec("wmic OS get FreePhysicalMemory | more +1"))) / 1024), // MB - 'BSD' => intval(intval(shell_exec("( sysctl vm.stats.vm.v_cache_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_inactive_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_active_count | grep -Eo '[0-9]+' ) | awk '{s+=$1} END {print s}'")) * intval(shell_exec("pagesize")) / 1024 / 1024), // MB - default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), + 'Windows' => $memoryTotal - intval(((int) trim(shell_exec('wmic OS get FreePhysicalMemory | more +1'))) / 1024), // MB + 'BSD' => intval(intval(shell_exec("( sysctl vm.stats.vm.v_cache_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_inactive_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_active_count | grep -Eo '[0-9]+' ) | awk '{s+=$1} END {print s}'")) * intval(shell_exec('pagesize')) / 1024 / 1024), // MB + default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), }; return [ From 670ca90d51f339fa3fce37e7520f8d69e1fafd6f Mon Sep 17 00:00:00 2001 From: TomatoPana <22053906+TomatoPana@users.noreply.github.com> Date: Sun, 7 Dec 2025 19:55:02 -0600 Subject: [PATCH 4/7] feat: Nevermind, don't mess with supported versions --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 091a96e0..3fd2df96 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "^8.2", + "php": "^8.1", "guzzlehttp/promises": "^1.0|^2.0", "doctrine/sql-formatter": "^1.4.1", "illuminate/auth": "^10.48.4|^11.0.8|^12.0", From 165d225c14f5999e2aedf03e6f4e19bb17731cff Mon Sep 17 00:00:00 2001 From: TomatoPana <22053906+TomatoPana@users.noreply.github.com> Date: Sun, 7 Dec 2025 20:07:27 -0600 Subject: [PATCH 5/7] feat: fixed the test workflow. `cachewerk/relay` was not installing in PHP 8.5 causing tests to fail (The extension relay was present so the tests were not skipped) --- .github/workflows/tests.yml | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f5a2327c..9dd1121f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,10 +4,10 @@ on: push: branches: - master - - '*.x' + - "*.x" pull_request: schedule: - - cron: '0 0 * * *' + - cron: "0 0 * * *" jobs: mysql: @@ -68,12 +68,11 @@ jobs: - name: Require cachewerk/relay run: | - composer require cachewerk/relay --no-interaction --no-update - if: matrix.php != 8.5 - + composer require cachewerk/relay --no-interaction --no-update + - name: Install dependencies run: | - composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} + composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} - name: Execute tests run: vendor/bin/pest -vvv @@ -131,12 +130,11 @@ jobs: - name: Require cachewerk/relay run: | - composer require cachewerk/relay --no-interaction --no-update - if: matrix.php != 8.5 - + composer require cachewerk/relay --no-interaction --no-update + - name: Install dependencies run: | - composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} + composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} - name: Execute tests run: vendor/bin/pest -vvv @@ -192,12 +190,11 @@ jobs: - name: Require cachewerk/relay run: | - composer require cachewerk/relay --no-interaction --no-update - if: matrix.php != 8.5 + composer require cachewerk/relay --no-interaction --no-update - name: Install dependencies run: | - composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} + composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} - name: Execute tests run: vendor/bin/pest -vvv @@ -244,12 +241,11 @@ jobs: - name: Require cachewerk/relay run: | - composer require cachewerk/relay --no-interaction --no-update - if: matrix.php != 8.5 + composer require cachewerk/relay --no-interaction --no-update - name: Install dependencies run: | - composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} + composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} - name: Execute tests run: vendor/bin/pest -vvv From 9006bac60423a8da98b0916c5fd8fbaa2be8cfe4 Mon Sep 17 00:00:00 2001 From: TomatoPana <22053906+TomatoPana@users.noreply.github.com> Date: Sun, 7 Dec 2025 20:17:00 -0600 Subject: [PATCH 6/7] feat: Fixed type errors reported by PHPStan --- src/Recorders/Servers.php | 28 ++++++++++++++-------------- src/Users.php | 5 +++-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Recorders/Servers.php b/src/Recorders/Servers.php index b05af49b..3fc4431a 100644 --- a/src/Recorders/Servers.php +++ b/src/Recorders/Servers.php @@ -72,7 +72,7 @@ public static function detectMemoryUsing(?callable $callback): void public function record(SharedBeat $event): void { $this->throttle(15, $event, function ($event) { - $server = $this->config->get('pulse.recorders.'.self::class.'.server_name'); + $server = $this->config->get('pulse.recorders.' . self::class . '.server_name'); $slug = Str::slug($server); ['total' => $memoryTotal, 'used' => $memoryUsed] = $this->memory(); @@ -85,9 +85,9 @@ public function record(SharedBeat $event): void 'cpu' => $cpu, 'memory_used' => $memoryUsed, 'memory_total' => $memoryTotal, - 'storage' => collect($this->config->get('pulse.recorders.'.self::class.'.directories')) // @phpstan-ignore argument.templateType, argument.templateType - ->filter(fn (string $directory) => ($this->pulse->rescue(fn () => disk_total_space($directory)) ?? false) !== false) - ->map(fn (string $directory) => [ + 'storage' => collect($this->config->get('pulse.recorders.' . self::class . '.directories')) // @phpstan-ignore argument.templateType, argument.templateType + ->filter(fn(string $directory) => ($this->pulse->rescue(fn() => disk_total_space($directory)) ?? false) !== false) + ->map(fn(string $directory) => [ 'directory' => $directory, 'total' => $total = intval(round(disk_total_space($directory) / 1024 / 1024)), // MB 'used' => intval(round($total - (disk_free_space($directory) / 1024 / 1024))), // MB @@ -109,9 +109,9 @@ protected function cpu(): int return match (PHP_OS_FAMILY) { 'Darwin' => (int) shell_exec("top -l 1 | grep -E \"^CPU\" | tail -1 | awk '{ print $3 + $5 }'"), 'Linux' => (int) shell_exec("top -bn1 | grep -E '^(%Cpu|CPU)' | awk '{ print $2 + $4 }'"), - 'Windows' => (int) trim(shell_exec('wmic cpu get loadpercentage | more +1')), + 'Windows' => (int) trim((string)shell_exec('wmic cpu get loadpercentage | more +1')), 'BSD' => (int) shell_exec("top -b -d 2| grep 'CPU: ' | tail -1 | awk '{print$10}' | grep -Eo '[0-9]+\.[0-9]+' | awk '{ print 100 - $1 }'"), - default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), + default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), }; } @@ -127,19 +127,19 @@ protected function memory(): array } $memoryTotal = match (PHP_OS_FAMILY) { - 'Darwin' => intval(shell_exec("sysctl hw.memsize | grep -Eo '[0-9]+'") / 1024 / 1024), - 'Linux' => intval(shell_exec("cat /proc/meminfo | grep MemTotal | grep -E -o '[0-9]+'") / 1024), - 'Windows' => intval(((int) trim(shell_exec('wmic ComputerSystem get TotalPhysicalMemory | more +1'))) / 1024 / 1024), - 'BSD' => intval(shell_exec("sysctl hw.physmem | grep -Eo '[0-9]+'") / 1024 / 1024), - default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), + 'Darwin' => intval(intval(shell_exec("sysctl hw.memsize | grep -Eo '[0-9]+'")) / 1024 / 1024), + 'Linux' => intval(intval(shell_exec("cat /proc/meminfo | grep MemTotal | grep -E -o '[0-9]+'")) / 1024), + 'Windows' => intval(((int) trim((string)shell_exec('wmic ComputerSystem get TotalPhysicalMemory | more +1'))) / 1024 / 1024), + 'BSD' => intval(intval(shell_exec("sysctl hw.physmem | grep -Eo '[0-9]+'")) / 1024 / 1024), + default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), }; $memoryUsed = match (PHP_OS_FAMILY) { 'Darwin' => $memoryTotal - intval(intval(shell_exec("vm_stat | grep 'Pages free' | grep -Eo '[0-9]+'")) * intval(shell_exec('pagesize')) / 1024 / 1024), // MB - 'Linux' => $memoryTotal - intval(shell_exec("cat /proc/meminfo | grep MemAvailable | grep -E -o '[0-9]+'") / 1024), // MB - 'Windows' => $memoryTotal - intval(((int) trim(shell_exec('wmic OS get FreePhysicalMemory | more +1'))) / 1024), // MB + 'Linux' => $memoryTotal - intval(shell_exec("cat /proc/meminfo | grep MemAvailable | grep -E -o '[0-9]+'")) / 1024, // MB + 'Windows' => $memoryTotal - intval(((int) trim((string)shell_exec('wmic OS get FreePhysicalMemory | more +1'))) / 1024), // MB 'BSD' => intval(intval(shell_exec("( sysctl vm.stats.vm.v_cache_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_inactive_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_active_count | grep -Eo '[0-9]+' ) | awk '{s+=$1} END {print s}'")) * intval(shell_exec('pagesize')) / 1024 / 1024), // MB - default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), + default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), }; return [ diff --git a/src/Users.php b/src/Users.php index 7de0b343..87ced139 100644 --- a/src/Users.php +++ b/src/Users.php @@ -47,9 +47,10 @@ public function load(Collection $keys): self if ($provider instanceof EloquentUserProvider) { $model = $provider->getModel(); + // @phpstan-ignore staticMethod.notFound $this->resolvedUsers = $model::findMany($keys); } else { - $this->resolvedUsers = $keys->map(fn ($key) => $provider->retrieveById($key)); + $this->resolvedUsers = $keys->map(fn($key) => $provider->retrieveById($key)); } return $this; @@ -62,7 +63,7 @@ public function load(Collection $keys): self */ public function find(int|string|null $key): object { - $user = $this->resolvedUsers->first(fn ($user) => $this->key($user) == $key); + $user = $this->resolvedUsers->first(fn($user) => $this->key($user) == $key); if ($this->fieldResolver !== null && $user !== null) { return (object) ($this->fieldResolver)($user); From d26ca49bb16ecc2430a5be2ed02a1145f4ecd5d6 Mon Sep 17 00:00:00 2001 From: TomatoPana <22053906+TomatoPana@users.noreply.github.com> Date: Mon, 8 Dec 2025 02:17:25 +0000 Subject: [PATCH 7/7] Fix code styling --- src/Recorders/Servers.php | 20 ++++++++++---------- src/Users.php | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Recorders/Servers.php b/src/Recorders/Servers.php index 3fc4431a..5dc0cca3 100644 --- a/src/Recorders/Servers.php +++ b/src/Recorders/Servers.php @@ -72,7 +72,7 @@ public static function detectMemoryUsing(?callable $callback): void public function record(SharedBeat $event): void { $this->throttle(15, $event, function ($event) { - $server = $this->config->get('pulse.recorders.' . self::class . '.server_name'); + $server = $this->config->get('pulse.recorders.'.self::class.'.server_name'); $slug = Str::slug($server); ['total' => $memoryTotal, 'used' => $memoryUsed] = $this->memory(); @@ -85,9 +85,9 @@ public function record(SharedBeat $event): void 'cpu' => $cpu, 'memory_used' => $memoryUsed, 'memory_total' => $memoryTotal, - 'storage' => collect($this->config->get('pulse.recorders.' . self::class . '.directories')) // @phpstan-ignore argument.templateType, argument.templateType - ->filter(fn(string $directory) => ($this->pulse->rescue(fn() => disk_total_space($directory)) ?? false) !== false) - ->map(fn(string $directory) => [ + 'storage' => collect($this->config->get('pulse.recorders.'.self::class.'.directories')) // @phpstan-ignore argument.templateType, argument.templateType + ->filter(fn (string $directory) => ($this->pulse->rescue(fn () => disk_total_space($directory)) ?? false) !== false) + ->map(fn (string $directory) => [ 'directory' => $directory, 'total' => $total = intval(round(disk_total_space($directory) / 1024 / 1024)), // MB 'used' => intval(round($total - (disk_free_space($directory) / 1024 / 1024))), // MB @@ -109,9 +109,9 @@ protected function cpu(): int return match (PHP_OS_FAMILY) { 'Darwin' => (int) shell_exec("top -l 1 | grep -E \"^CPU\" | tail -1 | awk '{ print $3 + $5 }'"), 'Linux' => (int) shell_exec("top -bn1 | grep -E '^(%Cpu|CPU)' | awk '{ print $2 + $4 }'"), - 'Windows' => (int) trim((string)shell_exec('wmic cpu get loadpercentage | more +1')), + 'Windows' => (int) trim((string) shell_exec('wmic cpu get loadpercentage | more +1')), 'BSD' => (int) shell_exec("top -b -d 2| grep 'CPU: ' | tail -1 | awk '{print$10}' | grep -Eo '[0-9]+\.[0-9]+' | awk '{ print 100 - $1 }'"), - default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), + default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), }; } @@ -129,17 +129,17 @@ protected function memory(): array $memoryTotal = match (PHP_OS_FAMILY) { 'Darwin' => intval(intval(shell_exec("sysctl hw.memsize | grep -Eo '[0-9]+'")) / 1024 / 1024), 'Linux' => intval(intval(shell_exec("cat /proc/meminfo | grep MemTotal | grep -E -o '[0-9]+'")) / 1024), - 'Windows' => intval(((int) trim((string)shell_exec('wmic ComputerSystem get TotalPhysicalMemory | more +1'))) / 1024 / 1024), + 'Windows' => intval(((int) trim((string) shell_exec('wmic ComputerSystem get TotalPhysicalMemory | more +1'))) / 1024 / 1024), 'BSD' => intval(intval(shell_exec("sysctl hw.physmem | grep -Eo '[0-9]+'")) / 1024 / 1024), - default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), + default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), }; $memoryUsed = match (PHP_OS_FAMILY) { 'Darwin' => $memoryTotal - intval(intval(shell_exec("vm_stat | grep 'Pages free' | grep -Eo '[0-9]+'")) * intval(shell_exec('pagesize')) / 1024 / 1024), // MB 'Linux' => $memoryTotal - intval(shell_exec("cat /proc/meminfo | grep MemAvailable | grep -E -o '[0-9]+'")) / 1024, // MB - 'Windows' => $memoryTotal - intval(((int) trim((string)shell_exec('wmic OS get FreePhysicalMemory | more +1'))) / 1024), // MB + 'Windows' => $memoryTotal - intval(((int) trim((string) shell_exec('wmic OS get FreePhysicalMemory | more +1'))) / 1024), // MB 'BSD' => intval(intval(shell_exec("( sysctl vm.stats.vm.v_cache_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_inactive_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_active_count | grep -Eo '[0-9]+' ) | awk '{s+=$1} END {print s}'")) * intval(shell_exec('pagesize')) / 1024 / 1024), // MB - default => throw new RuntimeException('The pulse:check command does not currently support ' . PHP_OS_FAMILY), + default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), }; return [ diff --git a/src/Users.php b/src/Users.php index 87ced139..e807bd3d 100644 --- a/src/Users.php +++ b/src/Users.php @@ -50,7 +50,7 @@ public function load(Collection $keys): self // @phpstan-ignore staticMethod.notFound $this->resolvedUsers = $model::findMany($keys); } else { - $this->resolvedUsers = $keys->map(fn($key) => $provider->retrieveById($key)); + $this->resolvedUsers = $keys->map(fn ($key) => $provider->retrieveById($key)); } return $this; @@ -63,7 +63,7 @@ public function load(Collection $keys): self */ public function find(int|string|null $key): object { - $user = $this->resolvedUsers->first(fn($user) => $this->key($user) == $key); + $user = $this->resolvedUsers->first(fn ($user) => $this->key($user) == $key); if ($this->fieldResolver !== null && $user !== null) { return (object) ($this->fieldResolver)($user);