* stripped string
*/
public static function stripComments($string) {
- return preg_replace("/^(#|--).*\R*/m", "", $string);
+ return preg_replace("/^(#|--).*\R*/m", "", ($string ?? ''));
}
/**
$uniqID = md5(uniqid(rand(), TRUE));
$info = pathinfo($name);
$basename = substr($info['basename'],
- 0, -(strlen(CRM_Utils_Array::value('extension', $info)) + (CRM_Utils_Array::value('extension', $info) == '' ? 0 : 1))
+ 0, -(strlen(CRM_Utils_Array::value('extension', $info, '')) + (CRM_Utils_Array::value('extension', $info, '') == '' ? 0 : 1))
);
- if (!self::isExtensionSafe(CRM_Utils_Array::value('extension', $info))) {
+ if (!self::isExtensionSafe(CRM_Utils_Array::value('extension', $info, ''))) {
// munge extension so it cannot have an embbeded dot in it
// The maximum length of a filename for most filesystems is 255 chars.
// We'll truncate at 240 to give some room for the extension.
}
$iconClasses = Civi::$statics[__CLASS__]['mimeIcons'];
foreach ($iconClasses as $text => $icon) {
- if (strpos($mimeType, $text) === 0) {
+ if (strpos(($mimeType ?? ''), $text) === 0) {
return $icon;
}
}
* In php8 the return value from is_dir() is always bool but in php7 it can be null.
*/
public static function isDir(?string $dir) {
+ if ($dir === NULL) {
+ return FALSE;
+ }
set_error_handler(function($errno, $errstr) {
// If this is open_basedir-related, convert it to an exception so we
// can catch it.