1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2025-01-31 12:01:39 +01:00

Fix ?: operator

This commit is contained in:
FreeScout 2022-02-03 23:30:48 -08:00
parent 9e8ebe17ea
commit a9a3863d05
28 changed files with 37 additions and 37 deletions

View File

@ -794,7 +794,7 @@ class Conversation extends Model
// Create customers if needed: Test <test1@example.com>
if (is_array($emails)) {
foreach ($emails as $i => $email) {
preg_match("/^(.+)\s+([^\s]+)$/", $email ?: '', $m);
preg_match("/^(.+)\s+([^\s]+)$/", $email ?? '', $m);
if (count($m) == 3) {
$customer_name = trim($m[1]);
$email_address = trim($m[2]);

View File

@ -629,7 +629,7 @@ class Customer extends Model
*/
public function getPhones($dummy_if_empty = false)
{
$phones = json_decode($this->phones ?: '', true);
$phones = json_decode($this->phones ?? '', true);
if (is_array($phones) && count($phones)) {
return $phones;
@ -732,7 +732,7 @@ class Customer extends Model
*/
public function getSocialProfiles($dummy_if_empty = false)
{
$social_profiles = json_decode($this->social_profiles ?: '', true);
$social_profiles = json_decode($this->social_profiles ?? '', true);
if (is_array($social_profiles) && count($social_profiles)) {
return json_decode($this->social_profiles, true);
@ -753,7 +753,7 @@ class Customer extends Model
*/
public function getWebsites($dummy_if_empty = false)
{
$websites = json_decode($this->websites ?: '', true);
$websites = json_decode($this->websites ?? '', true);
if (is_array($websites) && count($websites)) {
return $websites;
} elseif ($dummy_if_empty) {

View File

@ -52,7 +52,7 @@ class Email extends Model
// Email validation is not recommended:
// http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address/201378#201378
// So we just check for @
if (!preg_match('/@/', $email ?: '')) {
if (!preg_match('/@/', $email ?? '')) {
return false;
}
$email = filter_var($email, FILTER_SANITIZE_EMAIL);

View File

@ -101,7 +101,7 @@ class MailboxesController extends Controller
$accessible_route = '';
$mailbox_settings = $user->mailboxSettings($mailbox->id);
$access_permissions = json_decode($mailbox_settings->access ?: '');
$access_permissions = json_decode($mailbox_settings->access ?? '');
if ($access_permissions && is_array($access_permissions)) {
foreach ($access_permissions as $perm) {

View File

@ -70,7 +70,7 @@ class SystemController extends Controller
$non_writable_cache_file = '';
if (function_exists('shell_exec')) {
$non_writable_cache_file = shell_exec('find '.base_path('storage/framework/cache/data/').' -type f | xargs -I {} sh -c \'[ ! -w "{}" ] && echo {}\' 2>&1 | head -n 1');
$non_writable_cache_file = trim($non_writable_cache_file ?: '');
$non_writable_cache_file = trim($non_writable_cache_file ?? '');
if (!strstr($non_writable_cache_file, base_path('storage/framework/cache/data/'))) {
$non_writable_cache_file = '';
}

View File

@ -493,7 +493,7 @@ class Helper
{
// Remove all kinds of spaces after tags.
// https://stackoverflow.com/questions/3230623/filter-all-types-of-whitespace-in-php
$text = preg_replace("/^(.*)>[\r\n]*\s+/mu", '$1>', $text ?: '');
$text = preg_replace("/^(.*)>[\r\n]*\s+/mu", '$1>', $text ?? '');
// Remove <script> and <style> blocks.
$text = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $text);
@ -1320,7 +1320,7 @@ class Helper
*/
public static function getWorkerIdentifier()
{
return md5(config('app.key') ?: '');
return md5(config('app.key') ?? '');
}
public static function uploadFile($file, $allowed_exts = [], $allowed_mimes = [], $sanitize_file_name = true)

View File

@ -202,7 +202,7 @@ class Mail
if ($escape) {
foreach ($vars as $i => $var) {
$vars[$i] = htmlspecialchars($var ?: '');
$vars[$i] = htmlspecialchars($var ?? '');
}
}
@ -350,7 +350,7 @@ class Mail
if (is_array($emails)) {
$emails_array = $emails;
} else {
$emails_array = explode(',', $emails ?: '');
$emails_array = explode(',', $emails ?? '');
}
foreach ($emails_array as $i => $email) {
@ -469,7 +469,7 @@ class Mail
'precedence' => ['auto_reply', 'bulk', 'junk'],
'x-precedence' => ['auto_reply', 'bulk', 'junk'],
];
$headers = explode("\n", $headers_str ?: '');
$headers = explode("\n", $headers_str ?? '');
foreach ($autoresponder_headers as $auto_header => $auto_header_value) {
foreach ($headers as $header) {

View File

@ -181,7 +181,7 @@ class Module extends Model
{
$missing = [];
$list = explode(',', $required_extensions ?: '');
$list = explode(',', $required_extensions ?? '');
if (!is_array($list) || !count($list)) {
return [];
}

View File

@ -339,7 +339,7 @@ class User extends Authenticatable
} else {
//$mailbox = $this->mailboxesCanViewWithSettings(true)->where('id', $mailbox_id)->first();
$mailbox = $this->mailboxesSettings()->where('mailbox_id', $mailbox_id)->first();
if ($mailbox && !empty(json_decode($mailbox->access ?: ''))) {
if ($mailbox && !empty(json_decode($mailbox->access ?? ''))) {
return true;
}
}

View File

@ -24,7 +24,7 @@ if (! function_exists('e')) {
return $value->toHtml();
}
return htmlspecialchars($value ?: '', ENT_QUOTES, 'UTF-8', $doubleEncode);
return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8', $doubleEncode);
}
}

View File

@ -44,7 +44,7 @@ class QueryFormatter extends DataFormatter
public function escapeBindings($bindings)
{
foreach ($bindings as &$binding) {
$binding = htmlentities($binding ?: '', ENT_QUOTES, 'UTF-8', false);
$binding = htmlentities($binding ?? '', ENT_QUOTES, 'UTF-8', false);
}
return $bindings;

View File

@ -134,7 +134,7 @@ class JavascriptRenderer extends BaseJavascriptRenderer
return $uris;
}
if (substr($uri ?: '', 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri ?: '')) {
if (substr($uri ?? '', 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri ?? '')) {
return $uri;
}
return rtrim($root, '/') . "/$uri";

View File

@ -95,7 +95,7 @@ class PDOConnection extends PDO implements ConnectionInterface, ServerInfoAwareC
#[\ReturnTypeWillChange]
public function quote($value, $type = ParameterType::STRING)
{
return parent::quote($value ?: '', $type);
return parent::quote($value ?? '', $type);
}
/**

View File

@ -108,7 +108,7 @@ class ClearCommand extends Command
*/
protected function tags()
{
return array_filter(explode(',', $this->option('tags') ?: ''));
return array_filter(explode(',', $this->option('tags') ?? ''));
}
/**

View File

@ -100,7 +100,7 @@ class Str
public static function contains($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ($needle !== '' && mb_strpos($haystack ?: '', $needle) !== false) {
if ($needle !== '' && mb_strpos($haystack ?? '', $needle) !== false) {
return true;
}
}
@ -331,7 +331,7 @@ class Str
$position = strpos($subject, $search);
if ($position !== false) {
return substr_replace($subject, $replace ?: '', $position, strlen($search));
return substr_replace($subject, $replace ?? '', $position, strlen($search));
}
return $subject;
@ -350,7 +350,7 @@ class Str
$position = strrpos($subject, $search);
if ($position !== false) {
return substr_replace($subject, $replace ?: '', $position, strlen($search));
return substr_replace($subject, $replace ?? '', $position, strlen($search));
}
return $subject;

View File

@ -545,7 +545,7 @@ class Carbon extends DateTime implements JsonSerializable
$locale = setlocale(LC_NUMERIC, '0');
setlocale(LC_NUMERIC, 'C');
}
parent::__construct($time ?: '', $timezone);
parent::__construct($time ?? '', $timezone);
if (isset($locale)) {
setlocale(LC_NUMERIC, $locale);
}

View File

@ -139,7 +139,7 @@ class LaravelLogViewer
*/
public function getFileName()
{
return basename($this->file ?: '');
return basename($this->file ?? '');
}
/**

View File

@ -117,7 +117,7 @@ class TextDescriptor extends Descriptor
$this->writeText('<comment>Options:</comment>', $options);
foreach ($definition->getOptions() as $option) {
if (\strlen($option->getShortcut() ?: '') > 1) {
if (\strlen($option->getShortcut() ?? '') > 1) {
$laterOptions[] = $option;
continue;
}

View File

@ -47,11 +47,11 @@ abstract class Helper implements HelperInterface
*/
public static function strlen($string)
{
if (false === $encoding = mb_detect_encoding($string ?: '', null, true)) {
if (false === $encoding = mb_detect_encoding($string ?? '', null, true)) {
return \strlen($string);
}
return mb_strwidth($string ?: '', $encoding);
return mb_strwidth($string ?? '', $encoding);
}
/**
@ -65,7 +65,7 @@ abstract class Helper implements HelperInterface
*/
public static function substr($string, $from, $length = null)
{
if (false === $encoding = mb_detect_encoding($string ?: '', null, true)) {
if (false === $encoding = mb_detect_encoding($string ?? '', null, true)) {
return substr($string, $from, $length);
}

View File

@ -26,7 +26,7 @@ class HttpException extends \RuntimeException implements HttpExceptionInterface
$this->statusCode = $statusCode;
$this->headers = $headers;
parent::__construct($message ?: '', $code, $previous);
parent::__construct($message ?? '', $code, $previous);
}
public function getStatusCode()

View File

@ -535,7 +535,7 @@ class Router implements RegistrarContract, BindingRegistrar
*/
protected function prefix($uri)
{
return trim(trim($this->getLastGroupPrefix() ?: '', '/').'/'.trim($uri ?: '', '/'), '/') ?: '/';
return trim(trim($this->getLastGroupPrefix() ?? '', '/').'/'.trim($uri ?? '', '/'), '/') ?: '/';
}
/**

View File

@ -1398,7 +1398,7 @@ trait ValidatesAttributes
return $value->getSize() / 1024;
}
return mb_strlen($value ?: '');
return mb_strlen($value ?? '');
}
/**

View File

@ -253,7 +253,7 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler
*/
protected function getAuthenticatorsForAgent()
{
if (!$mode = strtolower($this->auth_mode ?: '')) {
if (!$mode = strtolower($this->auth_mode ?? '')) {
return $this->authenticators;
}

View File

@ -141,7 +141,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo
*/
public function setEncryption($encryption)
{
$encryption = strtolower($encryption ?: '');
$encryption = strtolower($encryption ?? '');
if ('tls' == $encryption) {
$this->params['protocol'] = 'tcp';
$this->params['tls'] = true;

View File

@ -58,7 +58,7 @@ class AcceptHeader
return $item;
}, preg_split('/\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\s*/',
$headerValue ?: '',
$headerValue ?? '',
0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)));
}

View File

@ -1298,7 +1298,7 @@ class Response
*/
protected function ensureIEOverSSLCompatibility(Request $request)
{
if (false !== stripos($this->headers->get('Content-Disposition') ?: '', 'attachment') && 1 == preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) && true === $request->isSecure()) {
if (false !== stripos($this->headers->get('Content-Disposition') ?? '', 'attachment') && 1 == preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) && true === $request->isSecure()) {
if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) {
$this->headers->remove('Cache-Control');
}

View File

@ -33,7 +33,7 @@ if (! function_exists('e')) {
return $value->toHtml();
}
return htmlspecialchars($value ?: '', ENT_QUOTES, 'UTF-8', $doubleEncode);
return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8', $doubleEncode);
}
}

View File

@ -21,7 +21,7 @@
<p>Done searching for translations, found <strong class="counter">N</strong> items!</p>
</div>
<div class="alert alert-success success-publish" style="display:none;">
<p>Done publishing translations for group '<?php echo htmlspecialchars($group ?: '') ?>'!</p>
<p>Done publishing translations for group '<?php echo htmlspecialchars($group ?? '') ?>'!</p>
</div>
<?php if(Session::has('successPublish')) : ?>
<div class="alert alert-info">