thephpleague / climate

PHP's best friend for the terminal.
http://climate.thephpleague.com
MIT License
1.87k stars 123 forks source link

[Warning] PHP Deprecated: strlen(): Passing null to parameter #1 #189

Open kekefreedog opened 2 years ago

kekefreedog commented 2 years ago

Hello,

I am using climate with PHP8.1, and I have this log : PHP Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /Users/Toto/Sites/Sandbox/vendor/league/climate/src/TerminalObject/Basic/BasicTerminalObject.php on line 21

To fix this warning message, I just add this $value && strlen($value) in https://github.com/thephpleague/climate/blob/637555fdf6285c8077297f326760d9d8a5112f28/src/TerminalObject/Basic/BasicTerminalObject.php#L21

protected function set($key, $value)
{
    if ($value && strlen($value)) {
        $this->$key = $value;
    }
}

Is it possible to include this fix in the next release ?

Best

kekefreedog commented 2 years ago

Same problem here : Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /Users/toto/Sites/LuckyPHP/vendor/league/climate/src

https://github.com/thephpleague/climate/blob/637555fdf6285c8077297f326760d9d8a5112f28/src/TerminalObject/Dynamic/Progress.php#L216

Fix :

// If this line has a label then set that this progress bar has a label line
if ($label && strlen($label) > 0) {
    $this->has_label_line = true;
}