-
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 (#305)
- Loading branch information
1 parent
81f55d6
commit 82eb15b
Showing
4 changed files
with
69 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,26 @@ | ||
<?php | ||
// phpcs:ignore Generic.Files.OneTraitPerFile, Generic.Files.OneObjectStructurePerFile | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Pdk\Base\Concern; | ||
|
||
/* | ||
* Ugly fix for the following error in php 8: | ||
* 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 | ||
{ | ||
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