Skip to content

[Lock] Add LockKeyNormalizer #60023

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

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from
Open

Conversation

valtzu
Copy link
Contributor

@valtzu valtzu commented Mar 23, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
License MIT

The Lock documentation mentions that the lock keys are serializable – however, it seems that's the case only if you're using native php serializer.

I'm proposing to add LockKeyNormalizer to make the example in the docs work the same when using Symfony Serializer too.

@valtzu valtzu requested a review from jderusse as a code owner March 23, 2025 12:41
@carsonbot carsonbot added this to the 7.3 milestone Mar 23, 2025
@valtzu valtzu force-pushed the lock-normalizer branch 2 times, most recently from 89d05b7 to d1cd6e1 Compare March 23, 2025 12:51
{
$key = (new \ReflectionClass(Key::class))->newInstanceWithoutConstructor();
foreach ($key->__sleep() as $serializedField) {
(fn () => $this->$serializedField = $data[$serializedField])->bindTo($key, Key::class)();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be more efficient to have one closure outside of the loop instead of many calls inside

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read your comment again after 4 months – the loop is now inside the closure 👍 😄

@@ -5,6 +5,7 @@ CHANGELOG
---

* Add support for `valkey:` / `valkeys:` schemes
* Add `LockKeyNormalizer`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be on a new 7.4 section?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should indeed be in a 7.4 section

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

class LockKeyNormalizer implements NormalizerInterface, DenormalizerInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add @auhor and a description?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done

@valtzu valtzu force-pushed the lock-normalizer branch from ab729b1 to a9201d2 Compare July 21, 2025 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy