Skip to content

Commit d220cab

Browse files
authored
Initialize options array (#22)
PHP 8 throws warnings when accessing an undefined key in an array. This PR adds default values to the `$options` array to avoid the warnings. Even though there are error suppression operators (`@`) before accessing those values, custom error handlers still received that error and log/output it.
1 parent 662257f commit d220cab

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
.idea/
2+
/composer.lock
3+
/vendor

src/RandomColor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ private function __construct() {}
3939

4040
static public function one($options = array())
4141
{
42+
$options = array_merge(['format' => '', 'hue' => [], 'luminosity' => ''], $options);
4243
$h = self::_pickHue($options);
4344
$s = self::_pickSaturation($h, $options);
4445
$v = self::_pickBrightness($h, $s, $options);

0 commit comments

Comments
 (0)