-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix deprecation warning on arrayAccess::offsetGet
- Loading branch information
1 parent
d784a66
commit 12a9fa2
Showing
4 changed files
with
68 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Pdk\Base\Concern; | ||
|
||
/* | ||
* Ugly fix for the following error in php 7: | ||
* Return type of MyParcelNL\Pdk\Base\Model\Model::offsetGet($offset) should either be compatible with | ||
* ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to | ||
* temporarily suppress the notice. | ||
* | ||
* @TODO: Remove this when we no longer have to support PHP 7. | ||
*/ | ||
if (PHP_VERSION_ID >= 80000) { | ||
trait OffsetGetByPhpVersion | ||
{ | ||
use OffsetGetPhp8; | ||
} | ||
} else { | ||
trait OffsetGetByPhpVersion | ||
Check notice on line 21 in src/Base/Concern/OffsetGetByPhpVersion.php Codacy Production / Codacy Static Code Analysissrc/Base/Concern/OffsetGetByPhpVersion.php#L21
|
||
{ | ||
use OffsetGetPhp7; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Pdk\Base\Concern; | ||
|
||
trait OffsetGetPhp7 | ||
{ | ||
/** | ||
* Get the value for a given offset. | ||
* | ||
* @param mixed $offset | ||
* | ||
* @return mixed | ||
*/ | ||
public function offsetGet($offset) | ||
{ | ||
return $this->getAttribute($offset); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** @noinspection PhpUndefinedClassInspection */ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Pdk\Base\Concern; | ||
|
||
trait OffsetGetPhp8 | ||
{ | ||
/** | ||
* Get the value for a given offset. | ||
* | ||
* @param mixed $offset | ||
* | ||
* @return mixed | ||
*/ | ||
public function offsetGet($offset): mixed | ||
{ | ||
return $this->getAttribute($offset); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters