-
Notifications
You must be signed in to change notification settings - Fork 20
Make deduplication configurable from env #94
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
base: 1.1.x
Are you sure you want to change the base?
Conversation
When in the context of PHPUnit tests, using a bootstrap file is not very convenient.
|
@mpdude please review |
| if ($envValue === 'false' || $envValue === '0') { | ||
| return self::$deduplication = false; | ||
| } | ||
|
|
||
| return self::$deduplication = true; |
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.
What is this doing here? Flipping self::$deduplication to some value as a side effect?
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.
🤔 what do you mean "a side effect"? If this piece of code is reached, then it means there is either no env var defined, or it is neither false nor 0. In that case, we should fallback to the value before this PR, which was true.
| } | ||
|
|
||
| if (self::$deduplication === true && self::$triggeredDeprecations[$link] > 1) { | ||
| if ((self::$deduplication ?? self::getDeduplicationFromEnv()) === true && self::$triggeredDeprecations[$link] > 1) { |
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.
self::$deduplication ?? self::getDeduplicationFromEnv() is a repeating pattern. I'd make a static function for it that returns self::$deduplication ?? ...whateverDerivedFromEnv...
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.
self::$type ?? self::getTypeFromEnv(); is also a repeating pattern (even more repeating in fact), so although I had the same idea as you, I thought I would be consistent with the existing code
That might explain 🤣 |
Well I actually reworked Here is what Claude went with: if ($envValue === 'false' || $envValue === '0') {
self::$deduplication = false;
} else {
self::$deduplication = true;
}
return self::$deduplication; |
|
So would you want to change the state of I see, as a kind of lazy initalization and avoiding the performance overhead of re-evaluating it every time... |
|
Yes, the performance overhead, and also, from a conceptual point of vue, env variables should be considered immutable. One should assume they are never going to change during the lifetime of a program. |
When in the context of PHPUnit tests, using a bootstrap file is not very convenient.
Prompted by doctrine/collections#472
Disclaimer: I used opencode + Claude Sonnet for this.