Skip to content

Commit 38bcb4e

Browse files
author
mje
committed
Replace array_* with Arr::* for 5.8 support
1 parent 8e34794 commit 38bcb4e

11 files changed

+30
-19
lines changed

src/Checks/ComposerWithDevDependenciesIsUpToDate.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BeyondCode\SelfDiagnosis\Checks;
44

55
use BeyondCode\SelfDiagnosis\Composer;
6+
use Illuminate\Support\Arr;
67

78
class ComposerWithDevDependenciesIsUpToDate implements Check
89
{
@@ -37,7 +38,7 @@ public function name(array $config): string
3738
*/
3839
public function check(array $config): bool
3940
{
40-
$additionalOptions = array_get($config, 'additional_options', '');
41+
$additionalOptions = Arr::get($config, 'additional_options', '');
4142

4243
$this->output = $this->composer->installDryRun($additionalOptions);
4344

src/Checks/ComposerWithoutDevDependenciesIsUpToDate.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BeyondCode\SelfDiagnosis\Checks;
44

55
use BeyondCode\SelfDiagnosis\Composer;
6+
use Illuminate\Support\Arr;
67

78
class ComposerWithoutDevDependenciesIsUpToDate implements Check
89
{
@@ -37,7 +38,7 @@ public function name(array $config): string
3738
*/
3839
public function check(array $config): bool
3940
{
40-
$additionalOptions = array_get($config, 'additional_options', '');
41+
$additionalOptions = Arr::get($config, 'additional_options', '');
4142

4243
$this->output = $this->composer->installDryRun('--no-dev ' . $additionalOptions);
4344

src/Checks/CorrectPhpVersionIsInstalled.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Filesystem\Filesystem;
66
use Composer\Semver\Semver;
7+
use Illuminate\Support\Arr;
78

89
class CorrectPhpVersionIsInstalled implements Check
910
{
@@ -65,6 +66,6 @@ public function message(array $config): string
6566
public function getRequiredPhpConstraint()
6667
{
6768
$composer = json_decode($this->filesystem->get(base_path('composer.json')), true);
68-
return array_get($composer, 'require.php');
69+
return Arr::get($composer, 'require.php');
6970
}
7071
}

src/Checks/DatabaseCanBeAccessed.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BeyondCode\SelfDiagnosis\Checks;
44

55
use DB;
6+
use Illuminate\Support\Arr;
67

78
class DatabaseCanBeAccessed implements Check
89
{
@@ -28,11 +29,11 @@ public function name(array $config): string
2829
public function check(array $config): bool
2930
{
3031
try {
31-
if (array_get($config, 'default_connection', true)) {
32+
if (Arr::get($config, 'default_connection', true)) {
3233
DB::connection()->getPdo();
3334
}
3435

35-
foreach (array_get($config, 'connections', []) as $connection) {
36+
foreach (Arr::get($config, 'connections', []) as $connection) {
3637
DB::connection($connection)->getPdo();
3738
}
3839

src/Checks/DirectoriesHaveCorrectPermissions.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace BeyondCode\SelfDiagnosis\Checks;
44

5+
use Illuminate\Support\Arr;
56
use Illuminate\Support\Collection;
67
use Illuminate\Filesystem\Filesystem;
78

@@ -54,7 +55,7 @@ public function message(array $config): string
5455
*/
5556
public function check(array $config): bool
5657
{
57-
$this->paths = Collection::make(array_get($config, 'directories', []));
58+
$this->paths = Collection::make(Arr::get($config, 'directories', []));
5859

5960
$this->paths = $this->paths->reject(function ($path) {
6061
return $this->filesystem->isWritable($path);

src/Checks/LocalesAreInstalled.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BeyondCode\SelfDiagnosis\Checks;
44

55
use BeyondCode\SelfDiagnosis\SystemFunctions;
6+
use Illuminate\Support\Arr;
67
use Illuminate\Support\Collection;
78

89
class LocalesAreInstalled implements Check
@@ -45,7 +46,7 @@ public function name(array $config): string
4546
*/
4647
public function check(array $config): bool
4748
{
48-
$this->missingLocales = new Collection(array_get($config, 'required_locales', []));
49+
$this->missingLocales = new Collection(Arr::get($config, 'required_locales', []));
4950
if ($this->missingLocales->isEmpty()) {
5051
return true;
5152
}

src/Checks/PhpExtensionsAreDisabled.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace BeyondCode\SelfDiagnosis\Checks;
44

5+
use Illuminate\Support\Arr;
56
use Illuminate\Support\Collection;
67

78
class PhpExtensionsAreDisabled implements Check
@@ -29,7 +30,7 @@ public function name(array $config): string
2930
*/
3031
public function check(array $config): bool
3132
{
32-
$this->extensions = Collection::make(array_get($config, 'extensions', []));
33+
$this->extensions = Collection::make(Arr::get($config, 'extensions', []));
3334
$this->extensions = $this->extensions->reject(function ($ext) {
3435
return extension_loaded($ext) === false;
3536
});

src/Checks/PhpExtensionsAreInstalled.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BeyondCode\SelfDiagnosis\Checks;
44

55
use Illuminate\Filesystem\Filesystem;
6+
use Illuminate\Support\Arr;
67
use Illuminate\Support\Collection;
78

89
class PhpExtensionsAreInstalled implements Check
@@ -53,8 +54,8 @@ public function message(array $config): string
5354
*/
5455
public function check(array $config): bool
5556
{
56-
$this->extensions = Collection::make(array_get($config, 'extensions', []));
57-
if (array_get($config, 'include_composer_extensions', false)) {
57+
$this->extensions = Collection::make(Arr::get($config, 'extensions', []));
58+
if (Arr::get($config, 'include_composer_extensions', false)) {
5859
$this->extensions = $this->extensions->merge($this->getExtensionsRequiredInComposerFile());
5960
$this->extensions = $this->extensions->unique();
6061
}
@@ -75,7 +76,7 @@ public function getExtensionsRequiredInComposerFile()
7576

7677
$extensions = [];
7778
foreach ($installedPackages as $installedPackage) {
78-
$filtered = array_where(array_keys(array_get($installedPackage, 'require', [])), function ($value, $key) {
79+
$filtered = Arr::where(array_keys(Arr::get($installedPackage, 'require', [])), function ($value, $key) {
7980
return starts_with($value, self::EXT);
8081
});
8182
foreach ($filtered as $extension) {

src/Checks/RedisCanBeAccessed.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace BeyondCode\SelfDiagnosis\Checks;
44

5+
use Illuminate\Support\Arr;
56
use Illuminate\Support\Facades\Redis;
67

78
class RedisCanBeAccessed implements Check
@@ -28,14 +29,14 @@ public function name(array $config): string
2829
public function check(array $config): bool
2930
{
3031
try {
31-
if (array_get($config, 'default_connection', true)) {
32+
if (Arr::get($config, 'default_connection', true)) {
3233
if (!$this->testConnection()) {
3334
$this->message = trans('self-diagnosis::checks.redis_can_be_accessed.message.default_cache');
3435
return false;
3536
}
3637
}
3738

38-
foreach (array_get($config, 'connections', []) as $connection) {
39+
foreach (Arr::get($config, 'connections', []) as $connection) {
3940
if (!$this->testConnection($connection)) {
4041
$this->message = trans('self-diagnosis::checks.redis_can_be_accessed.message.named_cache', [
4142
'name' => $connection,

src/Checks/ServersArePingable.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use BeyondCode\SelfDiagnosis\Exceptions\InvalidConfigurationException;
66
use BeyondCode\SelfDiagnosis\Server;
7+
use Illuminate\Support\Arr;
78
use Illuminate\Support\Collection;
89
use JJG\Ping;
910

@@ -34,7 +35,7 @@ public function name(array $config): string
3435
*/
3536
public function check(array $config): bool
3637
{
37-
$this->notReachableServers = $this->parseConfiguredServers(array_get($config, 'servers', []));
38+
$this->notReachableServers = $this->parseConfiguredServers(Arr::get($config, 'servers', []));
3839
if ($this->notReachableServers->isEmpty()) {
3940
return true;
4041
}
@@ -94,9 +95,9 @@ private function parseConfiguredServers(array $servers): Collection
9495
throw new InvalidConfigurationException('For servers in array notation, the host parameter is required.');
9596
}
9697

97-
$host = array_get($server, 'host');
98-
$port = array_get($server, 'port');
99-
$timeout = array_get($server, 'timeout', self::DEFAULT_TIMEOUT);
98+
$host = Arr::get($server, 'host');
99+
$port = Arr::get($server, 'port');
100+
$timeout = Arr::get($server, 'timeout', self::DEFAULT_TIMEOUT);
100101

101102
$result->push(new Server($host, $port, $timeout));
102103
} else if (is_string($server)) {

src/Checks/SupervisorProgramsAreRunning.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BeyondCode\SelfDiagnosis\Checks;
44

55
use BeyondCode\SelfDiagnosis\SystemFunctions;
6+
use Illuminate\Support\Arr;
67
use Illuminate\Support\Collection;
78

89
class SupervisorProgramsAreRunning implements Check
@@ -48,7 +49,7 @@ public function name(array $config): string
4849
*/
4950
public function check(array $config): bool
5051
{
51-
$this->notRunningPrograms = new Collection(array_get($config, 'programs', []));
52+
$this->notRunningPrograms = new Collection(Arr::get($config, 'programs', []));
5253
if ($this->notRunningPrograms->isEmpty()) {
5354
return true;
5455
}
@@ -69,7 +70,7 @@ public function check(array $config): bool
6970
return false;
7071
}
7172

72-
$restartedWithin = array_get($config, 'restarted_within', 0);
73+
$restartedWithin = Arr::get($config, 'restarted_within', 0);
7374
$programs = explode("\n" , $programs);
7475
foreach ($programs as $program) {
7576
/*

0 commit comments

Comments
 (0)