N°5302 - Replace deprecated php strlen usages (#308)

This commit is contained in:
bdalsass
2022-07-08 10:27:52 +02:00
committed by GitHub
parent 65c6e99a3f
commit 33054d306d
6 changed files with 53 additions and 26 deletions

View File

@@ -2855,6 +2855,36 @@ HTML;
return strlen($sString ?? '');
}
/**
* Helper around the native strlen() PHP method to test a string for null or empty value
*
* @link https://www.php.net/releases/8.1/en.php#deprecations_and_bc_breaks "Passing null to non-nullable internal function parameters is deprecated"
*
* @param string|null $sString
*
* @return boolean if string null or empty
* @since 3.0.2 N°5302
*/
public static function IsNullOrEmptyString(?string $sString): boolean
{
return $sString == null || strlen($sString) == 0;
}
/**
* Helper around the native strlen() PHP method to test a string not null or empty value
*
* @link https://www.php.net/releases/8.1/en.php#deprecations_and_bc_breaks "Passing null to non-nullable internal function parameters is deprecated"
*
* @param string|null $sString
*
* @return boolean if string is not null and not empty
* @since 3.0.2 N°5302
*/
public static function IsNotNullOrEmptyString(?string $sString): boolean
{
return !static::IsNullOrEmptyString($sString);
}
//----------------------------------------------
// Environment helpers
//----------------------------------------------