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

[8.x] Add explicit @return annotations in {@inheritdoc} from vendors and add some missing #[\ReturnTypeWillChange] #38819

Merged
merged 2 commits into from
Sep 15, 2021

Conversation

wouterj
Copy link
Contributor

@wouterj wouterj commented Sep 15, 2021

This PR introduces an @return annotation in PHPDoc blocks that reference {@inheritdoc} from a vendor (i.e. no Illuminate root namespace). This removes the need to rely on external knowledge to get some understanding of the annotations.

Besides that, this also functions as an opt-out for the type deprecations triggered by Symfony as of 5.4. Their function is similar to the #[\ReturnTypeWillChange] attribute: tell static analysers that you know the return type of the parent can be converted to a real type at any release, but you don't want to add the real type yourself yet (I think you will probably add these in Laravel 9?).

The type patcher script also discovered some missing #[\ReturnTypeWillChange] attributes (causing deprecations on PHP 8.1) and 2 cases where return; was used in combination with a null return type. The latter produces a fatal error once the type is introduced (https://3v4l.org/bK7Vt)

@wouterj wouterj changed the title Add explicit @return annotations in {@inheritdoc} from vendors and add some missing #[\ReturnTypeWillChange] [8.x] Add explicit @return annotations in {@inheritdoc} from vendors and add some missing #[\ReturnTypeWillChange] Sep 15, 2021
@GrahamCampbell
Copy link
Member

GrahamCampbell commented Sep 15, 2021

Can you target our php81-fixes branch instead please? Some of your changes already exist on that branch. :)

@wouterj wouterj changed the base branch from 8.x to php81-fixes September 15, 2021 10:34
@wouterj
Copy link
Contributor Author

wouterj commented Sep 15, 2021

Can you target our php81-fixes branch instead please?

Oh, didn't realize Laravel was using this type of branching strategy. PR rebased!

@GrahamCampbell
Copy link
Member

Oh, didn't realize Laravel was using this type of branching strategy. PR rebased!

Thanks. Yeh, it's only temporary. We'll be merging shortly. :)

@taylorotwell taylorotwell merged commit a8d5331 into laravel:php81-fixes Sep 15, 2021
@wouterj wouterj deleted the phpdoc-return branch September 15, 2021 13:02
@wouterj
Copy link
Contributor Author

wouterj commented Sep 15, 2021

Thanks for the quick review and merge! 🚀

taylorotwell added a commit that referenced this pull request Sep 15, 2021
* Add ReturnTypeWillChange to SessionHandlerInterface usages

* Bump commonmark

* Fix getIterator

* Use Symfony 5.4 components

* Dev mockery

* Mimic PHP 8.0

* Try removing symfony components

* Mockery

* Fix type errors in db tests (#38696)

* Fix type errors in db tests

* Apply fixes from StyleCI

Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>

* Additional DB test fixes (#38699)

* More DB fixes (#38700)

* PHP 8.1 prefer-lowest builds

* Remove skipping PHP 8.1 builds

* Bump PHPUnit

* Revert "PHP 8.1 prefer-lowest builds"

This reverts commit d5b01d2.

* [8.x] Adds PHP 8.1 support to serializable closures (#38801)

* Makes serializable closures work with PHP 8.1

* Apply fixes from StyleCI

* Fixes PHP 7.3 tests

* Refactors

* Updates deprecated warning

Co-authored-by: Dries Vints <dries@vints.io>

* Fixes restoring properties

* Update QueueServiceProvider.php

Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>
Co-authored-by: Dries Vints <dries@vints.io>
Co-authored-by: Taylor Otwell <taylor@laravel.com>

* Fix default value

* Fix mb_strlen value

* Adds `continue-on-error` for PHP 8.1

* [8.x] Add explicit `@return` annotations in `{@inheritdoc}` from vendors and add some missing `#[\ReturnTypeWillChange]` (#38819)

* Add explicit `@return` to `{@inheritdoc}` PHPDoc

* Use `return null;` when the return type is `null`

* Skips PHP 8.1 failing tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Update SerializableClosure.php

Co-authored-by: Graham Campbell <GrahamCampbell@users.noreply.github.com>
Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>
Co-authored-by: Nuno Maduro <enunomaduro@gmail.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
Co-authored-by: Wouter J <wouterj@users.noreply.github.com>
victorvilella pushed a commit to cdsistemas/framework that referenced this pull request Oct 12, 2021
* Add ReturnTypeWillChange to SessionHandlerInterface usages

* Bump commonmark

* Fix getIterator

* Use Symfony 5.4 components

* Dev mockery

* Mimic PHP 8.0

* Try removing symfony components

* Mockery

* Fix type errors in db tests (laravel#38696)

* Fix type errors in db tests

* Apply fixes from StyleCI

Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>

* Additional DB test fixes (laravel#38699)

* More DB fixes (laravel#38700)

* PHP 8.1 prefer-lowest builds

* Remove skipping PHP 8.1 builds

* Bump PHPUnit

* Revert "PHP 8.1 prefer-lowest builds"

This reverts commit d5b01d2.

* [8.x] Adds PHP 8.1 support to serializable closures (laravel#38801)

* Makes serializable closures work with PHP 8.1

* Apply fixes from StyleCI

* Fixes PHP 7.3 tests

* Refactors

* Updates deprecated warning

Co-authored-by: Dries Vints <dries@vints.io>

* Fixes restoring properties

* Update QueueServiceProvider.php

Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>
Co-authored-by: Dries Vints <dries@vints.io>
Co-authored-by: Taylor Otwell <taylor@laravel.com>

* Fix default value

* Fix mb_strlen value

* Adds `continue-on-error` for PHP 8.1

* [8.x] Add explicit `@return` annotations in `{@inheritdoc}` from vendors and add some missing `#[\ReturnTypeWillChange]` (laravel#38819)

* Add explicit `@return` to `{@inheritdoc}` PHPDoc

* Use `return null;` when the return type is `null`

* Skips PHP 8.1 failing tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Skips some more PHP 8.1 related tests

* Update SerializableClosure.php

Co-authored-by: Graham Campbell <GrahamCampbell@users.noreply.github.com>
Co-authored-by: Taylor Otwell <taylorotwell@users.noreply.github.com>
Co-authored-by: Nuno Maduro <enunomaduro@gmail.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
Co-authored-by: Wouter J <wouterj@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

3 participants