Skip to content

Fix various bool-type coercions #61103

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

Merged
merged 1 commit into from
Jul 15, 2025
Merged

Conversation

Girgias
Copy link
Contributor

@Girgias Girgias commented Jul 11, 2025

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

This is cherry-picking some of the commits from #60890 which are basically bugs.
Not sure what the commit naming policy is so do let me know if you want me to manually rebase and rename commits following some guidelines.

@carsonbot

This comment has been minimized.

@Girgias Girgias changed the base branch from 7.4 to 6.4 July 11, 2025 11:57
@@ -85,7 +85,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
$setters = $value->getMethodCalls();
$value->setMethodCalls($withers);
foreach ($setters as $call) {
$value->addMethodCall($call[0], $call[1], $call[2] ?? false);
$value->addMethodCall($call[0], $call[1], isset($call[2]) && $call[2]);
Copy link
Member

Choose a reason for hiding this comment

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

I would not change that, as we expect the third array value to be a boolean. Instead, we should fix the invalid usages of the method calls.

@OskarStark OskarStark modified the milestones: 7.4, 6.4 Jul 12, 2025
@nicolas-grekas nicolas-grekas changed the title Fix various to/from bool type coercions Fix various bool-type coercions Jul 15, 2025
@nicolas-grekas
Copy link
Member

Thank you @Girgias.

@nicolas-grekas nicolas-grekas merged commit 5d66cca into symfony:6.4 Jul 15, 2025
9 of 11 checks passed
@@ -128,7 +128,7 @@ public function disableMagicSet(): static
*/
public function isMagicCallEnabled(): bool
{
return (bool) ($this->magicMethods & PropertyAccessor::MAGIC_CALL);
return $this->magicMethods & PropertyAccessor::MAGIC_CALL;
Copy link
Contributor

Choose a reason for hiding this comment

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

isnt this producing an integer now?

Copy link
Member

Choose a reason for hiding this comment

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

see the return type, which cannot be bypassed

Copy link
Member

Choose a reason for hiding this comment

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

The return type will create an implicit cast to bool, which is precisely what @Girgias tries to deprecated in PHP 8.5 AFAICT.

Copy link
Member

Choose a reason for hiding this comment

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

correct, but this is not done yet :)

Copy link
Contributor

Choose a reason for hiding this comment

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

i dont understand it, why would you want to rely on not using strict_types=1 currently? also, why opening up a deprecation, if the future fix is adding back (bool) again?

Copy link
Member

Choose a reason for hiding this comment

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

Strict types was a bad idea that makes writing PHP more fragile, see https://github.com/Girgias/unify-typing-modes-rfc?tab=readme-ov-file#unintended-consequences-of-strict_types-mode
You might not agree but that's nonetheless the way Symfony does types.
The future is not adding back the cast. At least not before any vote happened on the topic.
So this change is just bringing consistency with the current policies.

Copy link
Contributor

Choose a reason for hiding this comment

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

right, i understand the POV a bit better now.

that said

Use of explicit casts to conform to type requirements

im fine with explicitness :) i mean, psalm complains about it 😅

@Girgias Girgias deleted the 6.4-bool-fixes branch July 15, 2025 19:04
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.

6 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