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:
parent
9e8ebe17ea
commit
a9a3863d05
@ -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]);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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 = '';
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -181,7 +181,7 @@ class Module extends Model
|
||||
{
|
||||
$missing = [];
|
||||
|
||||
$list = explode(',', $required_extensions ?: '');
|
||||
$list = explode(',', $required_extensions ?? '');
|
||||
if (!is_array($list) || !count($list)) {
|
||||
return [];
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
2
artisan
2
artisan
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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";
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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') ?? ''));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ class LaravelLogViewer
|
||||
*/
|
||||
public function getFileName()
|
||||
{
|
||||
return basename($this->file ?: '');
|
||||
return basename($this->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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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 ?? '', '/'), '/') ?: '/';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1398,7 +1398,7 @@ trait ValidatesAttributes
|
||||
return $value->getSize() / 1024;
|
||||
}
|
||||
|
||||
return mb_strlen($value ?: '');
|
||||
return mb_strlen($value ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -58,7 +58,7 @@ class AcceptHeader
|
||||
|
||||
return $item;
|
||||
}, preg_split('/\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\s*/',
|
||||
$headerValue ?: '',
|
||||
$headerValue ?? '',
|
||||
0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)));
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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">
|
||||
|
Loading…
x
Reference in New Issue
Block a user