-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Migrate Cache namespace to php 8 #10210
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
Conversation
f804f5e
to
e04be42
Compare
@@ -43,6 +43,9 @@ | |||
</NullableReturnStatement> | |||
</file> | |||
<file src="lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php"> | |||
<InvalidScalarArgument occurrences="1"> | |||
<code>$data</code> | |||
</InvalidScalarArgument> |
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.
This doesn't seem to be an issue with Psalm v5: https://psalm.dev/r/6cd352a83c
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.
This one comes with a controversial change […]: switching
@readonly
properties to nativereadonly
.
That was then plan after all. Good job. 🙂
I had to tweak some tests to achieve that, and I've extracted that part in a separate commit, which I can backport if you think it should happen.
I think that would be a good idea.
I think, Doctrine\ORM\Cache\CacheKey::$hash
can also be declared as readonly
. Can you have a look?
@@ -58,7 +58,7 @@ public function get(CacheKey $key): CacheEntry|null | |||
public function getMultiple(CollectionCacheEntry $collection): array|null | |||
{ | |||
$keys = array_map( | |||
Closure::fromCallable([$this, 'getCacheEntryKey']), | |||
Closure::fromCallable($this->getCacheEntryKey(...)), |
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.
Closure::fromCallable($this->getCacheEntryKey(...)), | |
$this->getCacheEntryKey(...), |
There are a few more I missed, probably got distracted during my |
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.
I think, Doctrine\ORM\Cache\CacheKey::$hash can also be declared as readonly. Can you have a look?
I haven't done a deeper look into it, but does it make sense to introduce a constructor for the abstract class?
$generateKeys = static function ($id) use ($assocMetadata): EntityCacheKey { | ||
return new EntityCacheKey($assocMetadata->rootEntityName, $id); | ||
}; | ||
$generateKeys = static fn ($id): EntityCacheKey => new EntityCacheKey($assocMetadata->rootEntityName, $id); |
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.
The second argument of EntityCacheKey
is an array.
$generateKeys = static fn ($id): EntityCacheKey => new EntityCacheKey($assocMetadata->rootEntityName, $id); | |
$generateKeys = static fn (array $id): EntityCacheKey => new EntityCacheKey($assocMetadata->rootEntityName, $id); |
e04be42
to
616fcdc
Compare
This causes ~300 errors and failures in the test suite, |
616fcdc
to
c48ac76
Compare
Ah maybe that's an easy way to fix it, yes 🤔 |
c48ac76
to
bf605ab
Compare
@SenseException that was it, thanks! I left out a few more instances of |
Awesome. 🙈 Let's do this in a follow-up then. |
They all stemmed from the same 5 or so lines, after following @SenseException recommendation, they're gone 🙂 |
3d729a7
bf605ab
to
3d729a7
Compare
This one comes with a controversial change that I did not have the courage to extract to a separate commit PR/commit (feel free to insist I do so): switching
@readonly
properties to nativereadonly
. I had to tweak some tests to achieve that, and I've extracted that part in a separate commit, which I can backport if you think it should happen.