Skip to content

Supported "Marking" enum php #50311

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

Closed
wants to merge 2 commits into from
Closed

Supported "Marking" enum php #50311

wants to merge 2 commits into from

Conversation

Fuck4ik
Copy link

@Fuck4ik Fuck4ik commented May 12, 2023

Q A
Branch? 6.3
Bug fix? no
New feature? yes
Deprecations? no
Tickets
License MIT
Doc PR

I would like to be able to use the getters and setters of my entity with the enum type without custom implements MarkingStoreInterface.

Because php does not support enum in associative arrays, and \WeakMap is not suitable for this case, it was decided to make a method getEnumPlaces

@Fuck4ik Fuck4ik requested a review from lyrixx as a code owner May 12, 2023 20:55
@carsonbot carsonbot added this to the 6.3 milestone May 12, 2023
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@Fuck4ik Fuck4ik changed the title Supported "Marking" enum php [Workflow] Supported "Marking" enum php May 12, 2023
@stof
Copy link
Member

stof commented May 12, 2023

Places are strings in the workflow component. See #44211 for the discussion about the support for enums in that component.

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

Thank you for your attempt to improve Symfony. Please implement all changes in a backwards-compatible manner. Here's an overview of what you can and cannot change: https://symfony.com/doc/current/contributing/code/bc.html#working-on-symfony-code

* @return void
*/
public function mark(string $place)
public function mark(string|\UnitEnum $place): void
Copy link
Member

Choose a reason for hiding this comment

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

Note that this method is not final and could be overridden downstream. Widening the parameter type and narrowing the native return type are both breaking changes.

Copy link
Author

Choose a reason for hiding this comment

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

I propose to make Marking.php the final class

Copy link
Member

Choose a reason for hiding this comment

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

We cannot do that now, as making a class final is also a breaking change. So we can at most flag it as final using PHPdoc and make it final in 7.0. But that would also mean that we probably need to introduce a MarkingInterface and update the rest of the component to use that typehint, as otherwise this is fully closed for extension.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, you're right, it's better to leave it like that than to make many changes in favor of MarkingInterface

@carsonbot carsonbot changed the title [Workflow] Supported "Marking" enum php Supported "Marking" enum php May 12, 2023
@Fuck4ik
Copy link
Author

Fuck4ik commented May 12, 2023

Places are strings in the workflow component. See #44211 for the discussion about the support for enums in that component.

Thank you, I have read. Nevertheless, the desire to use enum is still present, and this decision turned out to be not so cumbersome and critical.

@stof
Copy link
Member

stof commented May 12, 2023

"Desire" to use a PHP feature in your own code does not exempt your contribution from respecting required rules of all contributions submitted to Symfony (as we cannot accept it if it breaks BC)

@Fuck4ik
Copy link
Author

Fuck4ik commented May 13, 2023

"Desire" to use a PHP feature in your own code does not exempt your contribution from respecting required rules of all contributions submitted to Symfony (as we cannot accept it if it breaks BC)

I understand you and completely agree. Nevertheless, this feature will be useful to many users.
In modern development, few people use enums as strings anymore. And this problem has to be solved with crutches like two properties "status" and "statusAsString"

@nicolas-grekas nicolas-grekas modified the milestones: 6.3, 6.4 May 23, 2023
@nicolas-grekas nicolas-grekas modified the milestones: 6.4, 7.1 Nov 15, 2023
@xabbuh xabbuh modified the milestones: 7.1, 7.2 May 15, 2024
@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@fabpot
Copy link
Member

fabpot commented Jan 5, 2025

Closing as we don't merge PRs with BC breaks.

@fabpot fabpot closed this Jan 5, 2025
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.

8 participants