Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Symfony 7.0 Type Declarations: Requesting Feedback from the Community #51563

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
wouterj opened this issue Sep 5, 2023 · 11 comments
Closed

Symfony 7.0 Type Declarations: Requesting Feedback from the Community #51563

wouterj opened this issue Sep 5, 2023 · 11 comments

Comments

@wouterj
Copy link
Member

wouterj commented Sep 5, 2023

Symfony 7.0 will come with type declarations to almost all methods, parameters and properties. See this blogpost for all information.

We acknowledge that introducing types impacts the whole Symfony open source ecosystem. As adding a type is a BC break, libraries are forced to release a new major version between now and December. Based on the experiences of bundles maintained by the Symfony team, we've postponed some impactful types to Symfony 8.0 already (increasing the timeframe for a new major version with two years).

We are open to, on a case by case basis, consider postponing more type declarations. If your library is blocked by one of the types we introduced, we would love to hear from you.

Test compatibility with 6.4/7.0 as early as possible by following these steps:

  1. Update your Symfony dependencies to 6.4-dev, and temporarily install the symfony/error-handler component.

  2. Run the type patch script twice:

    # the script relies on Composer's class map, check "exclude-from-classmap" in composer.json
    $ composer dump-autoload -o
    $ SYMFONY_PATCH_TYPE_DECLARATIONS=force=1 ./vendor/bin/patch-type-declarations
    $ SYMFONY_PATCH_TYPE_DECLARATIONS=force=1 ./vendor/bin/patch-type-declarations
  3. The script patches any methods that are private, final, @internal or tests (i.e. methods that can safely be updated).

    The second run reports deprecations for methods that are not patched. Please double check if the unpatched methods should not be final or internal (i.e. should a user really extend or use this class?).

  4. For the left-over deprecations, check if the type exists in the 7.0 branch. The 7.0 branch reflects the actual state, as postponed types will still trigger a deprecation in 6.4. You can suppress these deprections by adding the correct @return PHPdoc.

    If this is the case, please leave a comment with all details below.

Thanks for helping us towards type safety!

@driesvints
Copy link
Contributor

driesvints commented Sep 15, 2023

Hey @wouterj. We've started testing Symfony 6.4 on Laravel v10 and Symfony v7.0 on upcoming Laravel v11. Currently seeing CI failures but we'll first weed out the ones we can solve ourselves before reporting back here.

@driesvints
Copy link
Contributor

@wouterj we got all the failures for 6.4 fixed so I think we're good on that front. For 7.0 we'll work on the CI failures in the upcoming weeks.

@crynobone
Copy link
Contributor

HI @wouterj, an update with Symfony 7 and Laravel 11, there's only one issue detailed in #51792

@driesvints
Copy link
Contributor

We've merged v7 support into Laravel v11. Got everything sorted there as well πŸ‘

@bradjones1
Copy link
Contributor

Dropping in here from Drupal-land (though I am far from a core maintainer, hopefully they can/will chime in here as well.)

The earliest Drupal could do this wholesale is Drupal 11, which is tentatively scheduled for June, Sept. or Dec. 2024. Here's the Symfony 7 compatibility issue in our tracker.

Personally I am working one issue (#52084) that would benefit from Symfony 7 in the Drupal 10 lifecycle, however I'm not sure our internal rules would even allow for that. From what I can see on the Serializer component, though, there are a lot of existing types in 6.x so there may not be too many compatibility issues there vs. other components.

If I have some spare CPU cycles in the coming week I'll try to whip up a test run that applies the instructions in this issue and generates a report on our major items.

@bradjones1
Copy link
Contributor

Drupal does not appear to have any significant blockers from 6.4, however we are likely having to fork ContainerAwareTrait in to our own codebase as deprecating and removing it in our release cycle is disruptive.

@wouterj
Copy link
Member Author

wouterj commented Nov 6, 2023

Thanks for checking in @bradjones1! Does this mean that Drupal doesn't see any type deprecation? That would be great news, otherwise we need to know before the end of the month (especially if the type is void, we would be open to postpone them to 8.0 to help communities like Drupal).

@bradjones1
Copy link
Contributor

@wouterj There's a chance I could be missing something here, but our PHPstan baseline only had to add deprecations for ContainerAwareInterface and otherwise our test suite passes with 6.4.

Interestingly, I can't easily run the patch script as in the IS because Drupal dynamically adds modules to the autoloader depending on runtime configuration and I'm pretty confident that the testing in the CI suite (we recently added phpstan to all the things) would catch these issues anyway.

@curry684
Copy link
Contributor

Note that phpstan doesn't catch all type declaration and compatibility issues until level 6, and Drupal is afaics running at level 1 right now. It's not the most reliable indicator yet at this point.

@bradjones1
Copy link
Contributor

Good point. This is configurable on our new CI so let me play with that this weekend.

@wouterj
Copy link
Member Author

wouterj commented Dec 4, 2023

As Symfony 7.0 is released last week, I'm closing this issue.

Thanks to everyone for testing their apps against our pre-releases!

@wouterj wouterj closed this as completed Dec 4, 2023
@wouterj wouterj unpinned this issue Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants