-
Notifications
You must be signed in to change notification settings - Fork 1.5k
PHPORM-150 Run CI on Laravel 11 #2735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
namespace MongoDB\Laravel\Eloquent; | ||
|
||
use BackedEnum; | ||
use Carbon\CarbonInterface; | ||
use DateTimeInterface; | ||
use Illuminate\Contracts\Queue\QueueableCollection; | ||
|
@@ -22,6 +23,7 @@ | |
use MongoDB\BSON\UTCDateTime; | ||
use MongoDB\Laravel\Query\Builder as QueryBuilder; | ||
use Stringable; | ||
use ValueError; | ||
|
||
use function array_key_exists; | ||
use function array_keys; | ||
|
@@ -38,10 +40,12 @@ | |
use function is_string; | ||
use function ltrim; | ||
use function method_exists; | ||
use function sprintf; | ||
use function str_contains; | ||
use function str_starts_with; | ||
use function strcmp; | ||
use function uniqid; | ||
use function var_export; | ||
|
||
abstract class Model extends BaseModel | ||
{ | ||
|
@@ -704,7 +708,7 @@ protected function addCastAttributesToArray(array $attributes, array $mutatedAtt | |
} | ||
|
||
if ($this->isEnumCastable($key) && (! $castValue instanceof Arrayable)) { | ||
$castValue = $castValue !== null ? $this->getStorableEnumValue($castValue) : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The signature of this method have changed in a non-backward compatible way. So I duplicated this simple method to keep compatibility with both Laravel 10 and 11. We must keep the function |
||
$castValue = $castValue !== null ? $this->getStorableEnumValueFromLaravel11($this->getCasts()[$key], $castValue) : null; | ||
} | ||
|
||
if ($castValue instanceof Arrayable) { | ||
|
@@ -717,6 +721,23 @@ protected function addCastAttributesToArray(array $attributes, array $mutatedAtt | |
return $attributes; | ||
} | ||
|
||
/** | ||
* Duplicate of {@see HasAttributes::getStorableEnumValue()} for Laravel 11 as the signature of the method has | ||
* changed in a non-backward compatible way. | ||
* | ||
* @todo Remove this method when support for Laravel 10 is dropped. | ||
*/ | ||
private function getStorableEnumValueFromLaravel11($expectedEnum, $value) | ||
{ | ||
if (! $value instanceof $expectedEnum) { | ||
throw new ValueError(sprintf('Value [%s] is not of the expected enum type [%s].', var_export($value, true), $expectedEnum)); | ||
} | ||
|
||
return $value instanceof BackedEnum | ||
? $value->value | ||
: $value->name; | ||
} | ||
|
||
/** | ||
* Is a value a BSON type? | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -614,11 +614,7 @@ public function orderBy($column, $direction = 'asc') | |
return $this; | ||
} | ||
|
||
/** | ||
* @param list{mixed, mixed}|CarbonPeriod $values | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This signature was causing psalm error. Param type incompatible with the parent method. |
||
* | ||
* @inheritdoc | ||
*/ | ||
/** @inheritdoc */ | ||
public function whereBetween($column, iterable $values, $boolean = 'and', $not = false) | ||
{ | ||
$type = 'between'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once Laravel 11 will be released, this will no longer be necessary. But only
low-deps
job will run Laravel 10.