From 27a3e3e24e4515602bd18c45dd5ac170abfa7790 Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 27 Nov 2023 15:56:28 +1100 Subject: [PATCH] Use ObjectIssetFix Trait instead of defining __isset() directly --- app/Classes/FTN/Message.php | 10 ++-------- app/Jobs/AddressPoll.php | 28 ++++++---------------------- app/Traits/ObjectIssetFix.php | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 30 deletions(-) create mode 100644 app/Traits/ObjectIssetFix.php diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index 612ecb8..e6f3e35 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -13,7 +13,7 @@ use Illuminate\Validation\Validator as ValidatorResult; use App\Classes\FTN as FTNBase; use App\Models\{Address,Domain,Zone}; use App\Rules\{TwoByteInteger,TwoByteIntegerWithZero}; -use App\Traits\EncodeUTF8; +use App\Traits\{EncodeUTF8,ObjectIssetFix}; /** * Class Message @@ -24,7 +24,7 @@ use App\Traits\EncodeUTF8; */ class Message extends FTNBase { - use EncodeUTF8; + use EncodeUTF8,ObjectIssetFix; private const LOGKEY = 'FM-'; @@ -225,12 +225,6 @@ class Message extends FTNBase $this->unknown = collect(); } - // Fix for a call to pluck('date') (which is resolved via __get()), but it returns false. - public function __isset($key) - { - return (bool)$this->{$key}; - } - public function __get($key) { switch ($key) { diff --git a/app/Jobs/AddressPoll.php b/app/Jobs/AddressPoll.php index 8f41f1f..21244db 100644 --- a/app/Jobs/AddressPoll.php +++ b/app/Jobs/AddressPoll.php @@ -3,7 +3,6 @@ namespace App\Jobs; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Cache\Repository; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -11,7 +10,6 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\ManuallyFailedException; use Illuminate\Queue\MaxAttemptsExceededException; use Illuminate\Queue\SerializesModels; -use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Notification; @@ -21,18 +19,17 @@ use App\Classes\Sock\SocketClient; use App\Classes\Sock\SocketException; use App\Models\{Address,Mailer,Setup}; use App\Notifications\Netmails\PollingFailed; +use App\Traits\ObjectIssetFix; class AddressPoll implements ShouldQueue, ShouldBeUnique { + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, ObjectIssetFix; + private const LOGKEY = 'JAP'; - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - - public $tries = 5; - - public $maxExceptions = 1; - - public $failOnTimeout = TRUE; + public int $tries = 5; + public int $maxExceptions = 1; + public bool $failOnTimeout = TRUE; public const QUEUE = 'poll'; @@ -61,19 +58,6 @@ class AddressPoll implements ShouldQueue, ShouldBeUnique } } - /** - * Because pluck doesnt return __get() defined vars - * - * @param $key - * @return bool - */ - public function __isset($key): bool - { - $keys = ['address']; - - return in_array($key,$keys); - } - /** * Time to wait between tries * diff --git a/app/Traits/ObjectIssetFix.php b/app/Traits/ObjectIssetFix.php new file mode 100644 index 0000000..25f09a7 --- /dev/null +++ b/app/Traits/ObjectIssetFix.php @@ -0,0 +1,15 @@ +{$key}; + } +} \ No newline at end of file