-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Drop Flyweight pattern #5036
Drop Flyweight pattern #5036
Conversation
32179bb
to
ca8dfbb
Compare
dadfde0
to
abb477f
Compare
'aes-256-cbc-hmac-sha256', | ||
'/path/to/secret', | ||
$secretStore | ||
)); |
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.
Although this paragraph is a how-to, the one above it is as well, and the DBAL docs do not have a cookbook/how-to section. Not sure what to do.
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.
It's fine to keep it here.
Because this PR implements a new feature, it should target the 3.3.x branch. |
3c3b6af
to
87fa225
Compare
Given that the types are no longer identified by their names, what's the point of the name? |
If for some reason, you have 2 instances of |
I still have a feeling that it isn't the next step in refactoring the type system. If there's no clear understanding of whether the type names are needed, and the names are potentially related to the types being flyweights, I'd pause here and clean up the naming. The need to define the type name twice and declare it in the class dynamically depending on the implementation is a footgun that IMO needs to be addressed first of all. If you believe this PR is the right next step, we can proceed. |
87fa225
to
37006dd
Compare
@morozov there is no hurry for this PR, we can pause it. I noticed that there is no mention of Consequently, there is no need to deprecate |
52ac4c3
to
431b39e
Compare
Now that the confusion about using the type name twice has been eliminated in #5208, would it make sense to retarget this patch for |
Yes it would, I was planning on doing it soon ™️ |
431b39e
to
3effd54
Compare
dedac93
to
d92bd55
Compare
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.
Code-wise looks good. Just a few nitpicks on documentation and tests.
docs/en/reference/types.rst
Outdated
|
||
public function convertToPHPValue($value, AbstractPlatform $platform): string | ||
{ | ||
return openssl_decrypt( |
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.
IMO, encryption is a quite specific and sophisticated domain to be used to illustrate a concept of types. It's also not self-contain since it depends on a SecretStore
which isn't declared in the example.
It's better to use a dummy example with a prefix that doesn't distract from the subject.
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.
Ok, I tried to dumb it down to a less realistic but more simple use case.
tests/Types/TypeRegistryTest.php
Outdated
$this->registry->register('sameButDifferent', $newType); | ||
self::assertSame( | ||
$this->registry->get('some'), | ||
$this->registry->get('sameButDifferent') |
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.
"sameButDifferent" is really confusing to read. Why not just use some arbitrary keys like "type1" and "type2"? The fact that they are represented by the same object will be clear from the context and doesn't have to be expressed in the names.
'aes-256-cbc-hmac-sha256', | ||
'/path/to/secret', | ||
$secretStore | ||
)); |
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.
It's fine to keep it here.
There is a growing need for types with parameters, and that pattern was probably used out of concerns that are no longer relevant anyway.
d92bd55
to
96c2ebf
Compare
There is a growing need for types with parameters, and that pattern was
probably used out of concerns that are no longer relevant anyway.
The documentation needs to be updated, but sits in the wrong repository 🙈
EDIT: actually there is also one in this repository: https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#custom-mapping-types 🤔