Skip to content
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

NelmioApiDocBundle v5 overview #2215

Open
DjordyKoert opened this issue Feb 7, 2024 · 2 comments
Open

NelmioApiDocBundle v5 overview #2215

DjordyKoert opened this issue Feb 7, 2024 · 2 comments

Comments

@DjordyKoert
Copy link
Collaborator

DjordyKoert commented Feb 7, 2024

I think we should start preparing for NelmioApiDocBundle v5 and move forward with this bundle.

PHP 8.1+

First of all I would like to remove support for PHP 7. PHP 7 has been EOL for quite some time now (PHP 7.4 active support stopped 2 years ago https://endoflife.date/php) and is currently preventing us from using new PHP 8 features (typed properties, native attributes, property promotion, union types).

Additionally I would like to start using PHP 8.1 as a minimum instead of PHP 8.0 because:

  1. Enums (could replace https://github.com/nelmio/NelmioApiDocBundle/blob/daadb0b567c637d737f58fd25da0b4db2321560d/Render/Html/AssetsMode.php)
  2. new in initializers https://stitcher.io/blog/new-in-php-81#new-in-initializers-rfc
  3. readonly properties

Planned changes:

  • Rewrite every class for constructor property promotion
  • Add proper types for every class property

Static analysis

PHP 8 is also a perfect time to start using static analysis tools. That's why I would like to introduce (PHPStan) to this project. This would also include some refactoring here and there to remove PHPStan's detected problems.

Symfony version bump to 6.4+ Drop support for Symfony 6.0, 6.1, 6.2 & 6.3

Symfony 6.0, 6.1, 6.2 & 6.3 have already stopped receiving bug fixes & security updates which is why a bump to Symfony 6.4 would be ideal, this version also closely align with our new minimum PHP version support.
Additionaly let's keep supporting Symfony 5.4 for now. Support for it should be dropped in a different minor release. Preferably we wait until after November 2024 (end of bug fixes for Symfony 5.4 https://symfony.com/releases/5.4).

General refactoring

  • Remove current deprecations
  • Add proper return types to methods (including void)
    public function describe(array $types, Schema $property, array $groups = null /* , ?Schema $schema = null */ /* , array $context = [] */);
  • Add inline (union)types to methods where it is currently missing (this should also be detected by PHPStan)
  • Mark classes as final
    • All classes implementing PropertyDescriberInterface (prefer class decoration)
  • Drop support for sensio/framework-extra-bundle? (unmaintained & all annotations are available from Symfony 6.2 onward)
@DjordyKoert
Copy link
Collaborator Author

Try and and see if https://github.com/rectorphp/rector is a good solution for easy refactoring

@mathroc
Copy link

mathroc commented Apr 24, 2024

It could make upgrading harder, but it could be the opportunity to drop support for annotations. It seems to be that having both attributes & annotations adds a lot of complexity. Especially when the 2 are mixed

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

2 participants