Skip to content

Commit d6b7de0

Browse files
authored
Remove deprecated backticks (#471)
* feat: Bumping supported php Version and adjusted dependencies to install with PHP 8.5 * feat: replace deprecated backtick operators with `shell_exec` functions * Fix code styling * feat: Nevermind, don't mess with supported versions * 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) * feat: Fixed type errors reported by PHPStan * Fix code styling
1 parent d081a66 commit d6b7de0

File tree

4 files changed

+30
-31
lines changed

4 files changed

+30
-31
lines changed

.github/workflows/tests.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ on:
44
push:
55
branches:
66
- master
7-
- '*.x'
7+
- "*.x"
88
pull_request:
99
schedule:
10-
- cron: '0 0 * * *'
10+
- cron: "0 0 * * *"
1111

1212
jobs:
1313
mysql:
@@ -68,12 +68,11 @@ jobs:
6868

6969
- name: Require cachewerk/relay
7070
run: |
71-
composer require cachewerk/relay --no-interaction --no-update
72-
if: matrix.php != 8.5
73-
71+
composer require cachewerk/relay --no-interaction --no-update
72+
7473
- name: Install dependencies
7574
run: |
76-
composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }}
75+
composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }}
7776
7877
- name: Execute tests
7978
run: vendor/bin/pest -vvv
@@ -131,12 +130,11 @@ jobs:
131130

132131
- name: Require cachewerk/relay
133132
run: |
134-
composer require cachewerk/relay --no-interaction --no-update
135-
if: matrix.php != 8.5
136-
133+
composer require cachewerk/relay --no-interaction --no-update
134+
137135
- name: Install dependencies
138136
run: |
139-
composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }}
137+
composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }}
140138
141139
- name: Execute tests
142140
run: vendor/bin/pest -vvv
@@ -192,12 +190,11 @@ jobs:
192190

193191
- name: Require cachewerk/relay
194192
run: |
195-
composer require cachewerk/relay --no-interaction --no-update
196-
if: matrix.php != 8.5
193+
composer require cachewerk/relay --no-interaction --no-update
197194
198195
- name: Install dependencies
199196
run: |
200-
composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }}
197+
composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }}
201198
202199
- name: Execute tests
203200
run: vendor/bin/pest -vvv
@@ -244,12 +241,11 @@ jobs:
244241

245242
- name: Require cachewerk/relay
246243
run: |
247-
composer require cachewerk/relay --no-interaction --no-update
248-
if: matrix.php != 8.5
244+
composer require cachewerk/relay --no-interaction --no-update
249245
250246
- name: Install dependencies
251247
run: |
252-
composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }}
248+
composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }}
253249
254250
- name: Execute tests
255251
run: vendor/bin/pest -vvv

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"name": "laravel/pulse",
33
"description": "Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.",
4-
"keywords": ["laravel"],
4+
"keywords": [
5+
"laravel"
6+
],
57
"homepage": "https://github.com/laravel/pulse",
68
"license": "MIT",
79
"support": {
@@ -40,7 +42,7 @@
4042
"mockery/mockery": "^1.0",
4143
"orchestra/testbench": "^8.36|^9.15|^10.8",
4244
"pestphp/pest": "^2.0|^3.0|^4.0",
43-
"pestphp/pest-plugin-laravel": "^2.2",
45+
"pestphp/pest-plugin-laravel": "^2.2|^3.0|^4.0",
4446
"phpstan/phpstan": "^1.12.21",
4547
"predis/predis": "^1.0|^2.0"
4648
},
@@ -96,4 +98,4 @@
9698
"@php vendor/bin/pest"
9799
]
98100
}
99-
}
101+
}

src/Recorders/Servers.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ protected function cpu(): int
107107
}
108108

109109
return match (PHP_OS_FAMILY) {
110-
'Darwin' => (int) `top -l 1 | grep -E "^CPU" | tail -1 | awk '{ print $3 + $5 }'`,
111-
'Linux' => (int) `top -bn1 | grep -E '^(%Cpu|CPU)' | awk '{ print $2 + $4 }'`,
112-
'Windows' => (int) trim(`wmic cpu get loadpercentage | more +1`),
113-
'BSD' => (int) `top -b -d 2| grep 'CPU: ' | tail -1 | awk '{print$10}' | grep -Eo '[0-9]+\.[0-9]+' | awk '{ print 100 - $1 }'`,
110+
'Darwin' => (int) shell_exec("top -l 1 | grep -E \"^CPU\" | tail -1 | awk '{ print $3 + $5 }'"),
111+
'Linux' => (int) shell_exec("top -bn1 | grep -E '^(%Cpu|CPU)' | awk '{ print $2 + $4 }'"),
112+
'Windows' => (int) trim((string) shell_exec('wmic cpu get loadpercentage | more +1')),
113+
'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 }'"),
114114
default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY),
115115
};
116116
}
@@ -127,18 +127,18 @@ protected function memory(): array
127127
}
128128

129129
$memoryTotal = match (PHP_OS_FAMILY) {
130-
'Darwin' => intval(`sysctl hw.memsize | grep -Eo '[0-9]+'` / 1024 / 1024),
131-
'Linux' => intval(`cat /proc/meminfo | grep MemTotal | grep -E -o '[0-9]+'` / 1024),
132-
'Windows' => intval(((int) trim(`wmic ComputerSystem get TotalPhysicalMemory | more +1`)) / 1024 / 1024),
133-
'BSD' => intval(`sysctl hw.physmem | grep -Eo '[0-9]+'` / 1024 / 1024),
130+
'Darwin' => intval(intval(shell_exec("sysctl hw.memsize | grep -Eo '[0-9]+'")) / 1024 / 1024),
131+
'Linux' => intval(intval(shell_exec("cat /proc/meminfo | grep MemTotal | grep -E -o '[0-9]+'")) / 1024),
132+
'Windows' => intval(((int) trim((string) shell_exec('wmic ComputerSystem get TotalPhysicalMemory | more +1'))) / 1024 / 1024),
133+
'BSD' => intval(intval(shell_exec("sysctl hw.physmem | grep -Eo '[0-9]+'")) / 1024 / 1024),
134134
default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY),
135135
};
136136

137137
$memoryUsed = match (PHP_OS_FAMILY) {
138-
'Darwin' => $memoryTotal - intval(intval(`vm_stat | grep 'Pages free' | grep -Eo '[0-9]+'`) * intval(`pagesize`) / 1024 / 1024), // MB
139-
'Linux' => $memoryTotal - intval(`cat /proc/meminfo | grep MemAvailable | grep -E -o '[0-9]+'` / 1024), // MB
140-
'Windows' => $memoryTotal - intval(((int) trim(`wmic OS get FreePhysicalMemory | more +1`)) / 1024), // MB
141-
'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
138+
'Darwin' => $memoryTotal - intval(intval(shell_exec("vm_stat | grep 'Pages free' | grep -Eo '[0-9]+'")) * intval(shell_exec('pagesize')) / 1024 / 1024), // MB
139+
'Linux' => $memoryTotal - intval(shell_exec("cat /proc/meminfo | grep MemAvailable | grep -E -o '[0-9]+'")) / 1024, // MB
140+
'Windows' => $memoryTotal - intval(((int) trim((string) shell_exec('wmic OS get FreePhysicalMemory | more +1'))) / 1024), // MB
141+
'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
142142
default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY),
143143
};
144144

src/Users.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function load(Collection $keys): self
4747
if ($provider instanceof EloquentUserProvider) {
4848
$model = $provider->getModel();
4949

50+
// @phpstan-ignore staticMethod.notFound
5051
$this->resolvedUsers = $model::findMany($keys);
5152
} else {
5253
$this->resolvedUsers = $keys->map(fn ($key) => $provider->retrieveById($key));

0 commit comments

Comments
 (0)