Skip to content

Commit 89db374

Browse files
authored
chore: clean files for PHP 8.4 (#231)
1 parent ca1565f commit 89db374

3 files changed

Lines changed: 10 additions & 33 deletions

File tree

src/Environment.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace Rancoud\Environment;
66

7-
/**
8-
* Class Environment.
9-
*/
107
class Environment
118
{
129
public const int GETENV = 0x01;
@@ -47,15 +44,10 @@ class Environment
4744

4845
protected string $endline = \PHP_EOL;
4946

50-
/**
51-
* Environment constructor.
52-
*
53-
* @param array|string $folders
54-
*/
55-
public function __construct($folders, string $filename = '.env')
47+
public function __construct(array|string $folders, string $filename = '.env')
5648
{
5749
if (!\is_array($folders)) {
58-
$folders = [(string) $folders];
50+
$folders = [$folders];
5951
}
6052

6153
$this->folders = $folders;
@@ -228,8 +220,7 @@ protected function extractText(string $line): void
228220
}
229221
}
230222

231-
/** @return bool|float|int|string|null */
232-
protected function convertType(string $value): mixed
223+
protected function convertType(string $value): bool|float|int|string|null
233224
{
234225
$val = \mb_strtolower($value);
235226
if ($val === 'true') {
@@ -269,7 +260,7 @@ protected function replaceVariables(string $value): string
269260
return $value;
270261
}
271262

272-
protected function set(string $key, $value): void
263+
protected function set(string $key, mixed $value): void
273264
{
274265
$this->env[$key] = $value;
275266
}
@@ -287,11 +278,10 @@ protected function saveInCache(): void
287278
}
288279

289280
/**
290-
* @param mixed|null $default
291281
* @throws EnvironmentException
292282
* @return mixed|null
293283
*/
294-
public function get(string $key, $default = null)
284+
public function get(string $key, mixed $default = null): mixed
295285
{
296286
$this->autoload();
297287

@@ -310,17 +300,13 @@ public function getAll(): array
310300
return $this->env;
311301
}
312302

313-
/**
314-
* @param array|string $keys
315-
*
316-
* @throws EnvironmentException
317-
*/
318-
public function exists($keys): bool
303+
/** @throws EnvironmentException */
304+
public function exists(array|string $keys): bool
319305
{
320306
$this->autoload();
321307

322308
if (!\is_array($keys)) {
323-
$keys = [(string) $keys];
309+
$keys = [$keys];
324310
}
325311

326312
foreach ($keys as $key) {

src/EnvironmentException.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44

55
namespace Rancoud\Environment;
66

7-
/**
8-
* Class EnvironmentException.
9-
*/
107
class EnvironmentException extends \Exception {}

tests/EnvironmentTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
use Rancoud\Environment\Environment;
99
use Rancoud\Environment\EnvironmentException;
1010

11-
/**
12-
* Class EnvironmentTest.
13-
*
14-
* @internal
15-
*/
11+
/** @internal */
1612
class EnvironmentTest extends TestCase
1713
{
1814
protected array $fileEnvContent = [
@@ -64,10 +60,8 @@ class EnvironmentTest extends TestCase
6460
protected function getProtectedValue(Environment $env, string $name)
6561
{
6662
$reflexion = new \ReflectionClass(Environment::class);
67-
$prop = $reflexion->getProperty($name);
68-
$prop->setAccessible(true);
6963

70-
return $prop->getValue($env);
64+
return $reflexion->getProperty($name)->getValue($env);
7165
}
7266

7367
public function testBitmasking(): void

0 commit comments

Comments
 (0)