Commit Graph

44007 Commits

Author SHA1 Message Date
Nicolas Grekas
3debf910fb minor #33343 [ErrorHandler] make DebugClassLoader turn multi-types declarations to "object" (nicolas-grekas)
This PR was merged into the 4.4 branch.

Discussion
----------

[ErrorHandler] make DebugClassLoader turn multi-types declarations to "object"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

When `@return Foo|Bar` is found, this makes DebugClassLoader generate an `object` return type.
When all classes in the combo type contain `Iterator`, it generates an `iterable` type instead.

Commits
-------

0abd2712e9 [ErrorHandler] make DebugClassLoader turn multi-types declarations to "object"
2019-08-26 18:09:07 +02:00
Nicolas Grekas
0abd2712e9 [ErrorHandler] make DebugClassLoader turn multi-types declarations to "object" 2019-08-26 18:02:12 +02:00
Nicolas Grekas
6dd9d24e50 minor #33236 Add return-types with help from DebugClassLoader in the CI (nicolas-grekas)
This PR was merged into the 4.4 branch.

Discussion
----------

Add return-types with help from DebugClassLoader in the CI

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #33228
| License       | MIT
| Doc PR        | -

I've spent a great deal of time on this PR, experimenting with adding return types to the codebase.

TL;DR: my conclusion is that we cannot make it for 5.0.

There are two reasons for this:
1. The burden this will put on the community is immense, especially when considering that third party libs must also be updated for any apps to work at all on a return-typed 5.0. Symfony must add them last, not first.
2. We need return type covariance, yet this won't be available before PHP 7.4, while 5.0 supports 7.2.

What's attached?
- ~a draft patching logic in `DebugClassLoader` to add return-type where it discovers this should be done~
- return types added automatically thanks to #33283
- ~manual fixes for situations not handled (yet, if possible at all) by that logic in `DebugClassLoader`~ #33332

What's achieved? Tests are green \o/

At this stage, I think we have to acknowledge we won't add return-types in 5.0 but prepare a serious plan to add them in 6.0.

This plan could be:
- [x] make DebugClassLoader able to automate adding return types.
- [x] in 4.4: add all possible return types that don't break BC, e.g. in `Tests` and in generated code
- [x] spot and fix places where annotations aren't accurate, add more annotations where possible.
- [x] ensure `DebugClassLoader` triggers the best possible deprecations that encourage ppl to add return-types in their libs/apps. This means we could decide to disable the current ones (see #33235) and to re-enable them in 5.1. This will also give us the time to fine-tune the tooling (item 1. on this list)

Ideally, we could reach a point where we could test branch 4.4 *with* return-types: we'd use the tooling to add them automatically in the CI job, then we'd run tests and they should be green. Let's do this?

Help Wanted, here is how:

*With PHP 7.4*, run `php .github/patch-types.php`. This will add return types everywhere possible.

Then run tests, e.g. `./phpunit src/Symfony/Component/HttpFoundation --exclude-group legacy,issue-32995`

Here are the components that fail with return types added, please help me check them all with a PR on [my fork](https://github.com/nicolas-grekas/symfony/tree/eh-return-types):
 - [x] src/Symfony/Bridge/Doctrine
 - [x] src/Symfony/Bridge/Monolog
 - [x] src/Symfony/Bridge/PhpUnit
 - [x] src/Symfony/Bridge/ProxyManager
 - [x] src/Symfony/Bridge/Twig
 - [x] src/Symfony/Bundle/DebugBundle
 - [x] src/Symfony/Bundle/FrameworkBundle
 - [x] src/Symfony/Bundle/SecurityBundle
 - [x] src/Symfony/Bundle/TwigBundle
 - [x] src/Symfony/Bundle/WebProfilerBundle
 - [x] src/Symfony/Bundle/WebServerBundle
 - [x] src/Symfony/Component/Asset
 - [x] src/Symfony/Component/BrowserKit
 - [x] src/Symfony/Component/Cache
 - [x] https://github.com/nicolas-grekas/symfony/pull/28 src/Symfony/Component/Config
 - [x] src/Symfony/Component/Console
 - [x] src/Symfony/Component/CssSelector
 - [x] src/Symfony/Component/Debug
 - [x] https://github.com/nicolas-grekas/symfony/pull/28 src/Symfony/Component/DependencyInjection
 - [x] src/Symfony/Component/DomCrawler
 - [x] src/Symfony/Component/Dotenv
 - [x] src/Symfony/Component/ErrorHandler
 - [x] src/Symfony/Component/ErrorRenderer
 - [x] https://github.com/nicolas-grekas/symfony/pull/24 src/Symfony/Component/EventDispatcher
 - [x] src/Symfony/Component/ExpressionLanguage
 - [x] src/Symfony/Component/Filesystem
 - [x] src/Symfony/Component/Finder
 - [x] src/Symfony/Component/Form
 - [x] src/Symfony/Component/HttpClient
 - [x] src/Symfony/Component/HttpFoundation
 - [x] src/Symfony/Component/HttpKernel
 - [x] src/Symfony/Component/Inflector
 - [x] src/Symfony/Component/Intl
 - [x] src/Symfony/Component/Ldap
 - [x] src/Symfony/Component/Lock
 - [x] src/Symfony/Component/Mailer
 - [x] src/Symfony/Component/Messenger
 - [x] src/Symfony/Component/Mime
 - [x] src/Symfony/Component/OptionsResolver
 - [x] src/Symfony/Component/Process
 - [x] src/Symfony/Component/PropertyAccess
 - [x] src/Symfony/Component/PropertyInfo
 - [x] https://github.com/nicolas-grekas/symfony/pull/25 src/Symfony/Component/Routing
 - [x] https://github.com/nicolas-grekas/symfony/pull/26 src/Symfony/Component/Security
 - [x] src/Symfony/Component/Security/Core
 - [x] src/Symfony/Component/Security/Guard
 - [x] src/Symfony/Component/Security/Http
 - [x] https://github.com/nicolas-grekas/symfony/pull/29 src/Symfony/Component/Serializer
 - [x] src/Symfony/Component/Security/Csrf
 - [x] src/Symfony/Component/Stopwatch
 - [x] src/Symfony/Component/Templating
 - [x] https://github.com/nicolas-grekas/symfony/pull/27 src/Symfony/Component/Translation
 - [x] src/Symfony/Component/Validator
 - [x] src/Symfony/Component/VarDumper
 - [x] src/Symfony/Component/VarExporter
 - [x] src/Symfony/Component/WebLink
 - [x] src/Symfony/Component/Workflow
 - [x] src/Symfony/Component/Yaml
 - [x] src/Symfony/Contracts

Commits
-------

11149a1fbb Add return-types with help from DebugClassLoader in the CI
2019-08-26 15:38:09 +02:00
Nicolas Grekas
11149a1fbb Add return-types with help from DebugClassLoader in the CI 2019-08-26 15:31:28 +02:00
Yonel Ceruto
db9549d775 minor #33336 [HttpKernel] do not mock removed getPublicDir() method (xabbuh)
This PR was merged into the 4.4 branch.

Discussion
----------

[HttpKernel] do not mock removed getPublicDir() method

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

54cb471 do not mock removed getPublicDir() method
2019-08-26 09:25:46 -04:00
Christian Flothmann
54cb4713b2 do not mock removed getPublicDir() method 2019-08-26 15:05:55 +02:00
Nicolas Grekas
d887a0d941 feature #33283 [ErrorHandler] make DebugClassLoader able to add return type declarations (nicolas-grekas)
This PR was merged into the 4.4 branch.

Discussion
----------

[ErrorHandler] make DebugClassLoader able to add return type declarations

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #33236
| License       | MIT
| Doc PR        | -

This is the current state of the patching logic I'm using in `DebugClassLoader`.
I run it after a `composer i -o` with the excluded classes emptied.
It's not perfect, it requires manual changes/review, but it did the job so far.

Patching is enabled with the `SYMFONY_PATCH_TYPE_DECLARATIONS` env var.
The value of the env var is an URL-encoded array, with the following parameters as of now:
- `force=0/1/docblock`:
  - `0` adds return types only to non-BC breaking places: internal/final/test methods;
  - `1` adds return types everywhere possible, potentially breaking BC with child classes that didn't declare the return types before;
  - `docblock` adds `@return` annotations to opt-out from deprecation notices that `DebugClassLoader` trigger otherwise - the annotation meaning: "I know a return type should be used here instead of an annotation, but I can't add it for BC reasons for now".
- `php71-compat=0/1`: to prevent using the `object` type when the code must be compatible with PHP 7.1

Commits
-------

72f6a970fc [ErrorHandler] make DebugClassLoader able to add return type declarations
2019-08-26 13:32:03 +02:00
Nicolas Grekas
a6e75fd84d Merge branch '4.3' into 4.4
* 4.3:
  [Bridge/Doctrine] fix review
2019-08-26 13:29:32 +02:00
Nicolas Grekas
861b483d83 Merge branch '3.4' into 4.3
* 3.4:
  [Bridge/Doctrine] fix review
2019-08-26 13:29:20 +02:00
Nicolas Grekas
0a00af2b77 [Bridge/Doctrine] fix review 2019-08-26 13:01:58 +02:00
Nicolas Grekas
72f6a970fc [ErrorHandler] make DebugClassLoader able to add return type declarations 2019-08-26 11:53:50 +02:00
Nicolas Grekas
123fc624e5 Merge branch '4.3' into 4.4
* 4.3:
  fix merge
  fix merge
2019-08-26 11:32:48 +02:00
Nicolas Grekas
97832ec5cd fix merge 2019-08-26 11:28:48 +02:00
Nicolas Grekas
5a6558b7fa fix merge 2019-08-26 11:20:32 +02:00
Nicolas Grekas
089097046b Merge branch '4.3' into 4.4
* 4.3: (23 commits)
  fix merge
  [SecurityBundle] fix return type declarations
  [BrowserKit] fix return type declarations
  [PropertyInfo] fix return type declarations
  [Bridge/Doctrine] fix return type declarations
  [Form] fix return type declarations
  [Console] fix return type declarations
  [Intl] fix return type declarations
  [Templating] fix return type declarations
  [DomCrawler] fix return type declarations
  [Validator] fix return type declarations
  [Process] fix return type declarations
  [Workflow] fix return type declarations
  [Cache] fix return type declarations
  [Serializer] fix return type declarations
  [Translation] fix return type declarations
  [DI] fix return type declarations
  [Config] fix return type declarations
  [HttpKernel] Fix return type declarations
  [Security] Fix return type declarations
  ...
2019-08-26 11:00:56 +02:00
Nicolas Grekas
9e154e7728 fix merge 2019-08-26 10:55:16 +02:00
Nicolas Grekas
74b2802197 Merge branch '3.4' into 4.3
* 3.4: (21 commits)
  [SecurityBundle] fix return type declarations
  [BrowserKit] fix return type declarations
  [PropertyInfo] fix return type declarations
  [Bridge/Doctrine] fix return type declarations
  [Form] fix return type declarations
  [Console] fix return type declarations
  [Intl] fix return type declarations
  [Templating] fix return type declarations
  [DomCrawler] fix return type declarations
  [Validator] fix return type declarations
  [Process] fix return type declarations
  [Workflow] fix return type declarations
  [Cache] fix return type declarations
  [Serializer] fix return type declarations
  [Translation] fix return type declarations
  [DI] fix return type declarations
  [Config] fix return type declarations
  [HttpKernel] Fix return type declarations
  [Security] Fix return type declarations
  [Routing] Fix return type declarations
  ...
2019-08-26 10:26:39 +02:00
Nicolas Grekas
e9886e4e4c minor #33332 [3.4] Fix return types declarations (nicolas-grekas, derrabus)
This PR was merged into the 3.4 branch.

Discussion
----------

[3.4] Fix return types declarations

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This is the subset of #33236 that applies to branch 3.4.
This PR ensures return types are correctly declared, and adjust some implementations that return incorrect types.

Commits
-------

2ceb453ee5 [SecurityBundle] fix return type declarations
c1d7a88b57 [BrowserKit] fix return type declarations
07405e2c60 [PropertyInfo] fix return type declarations
5f3b4b616b [Bridge/Doctrine] fix return type declarations
8706f18ea8 [Form] fix return type declarations
a32a713045 [Console] fix return type declarations
523e9b9feb [Intl] fix return type declarations
73f504c94a [Templating] fix return type declarations
2b8ef1d6d7 [DomCrawler] fix return type declarations
2ea98bb4a1 [Validator] fix return type declarations
6af0c80342 [Process] fix return type declarations
28646c7f9b [Workflow] fix return type declarations
5f9aaa743c [Cache] fix return type declarations
5072cfc7f8 [Serializer] fix return type declarations
70feaa407e [Translation] fix return type declarations
ca1fad471e [DI] fix return type declarations
9c63be489e [Config] fix return type declarations
05fe553666 [HttpKernel] Fix return type declarations
e0d79f71ed [Security] Fix return type declarations
c1b7118d7c [Routing] Fix return type declarations
ef5ead0005 [HttpFoundation] fix return type declarations
2019-08-26 10:20:21 +02:00
Nicolas Grekas
2ceb453ee5 [SecurityBundle] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
c1d7a88b57 [BrowserKit] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
07405e2c60 [PropertyInfo] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
5f3b4b616b [Bridge/Doctrine] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
8706f18ea8 [Form] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
a32a713045 [Console] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
523e9b9feb [Intl] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
73f504c94a [Templating] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
2b8ef1d6d7 [DomCrawler] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
2ea98bb4a1 [Validator] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
6af0c80342 [Process] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
28646c7f9b [Workflow] fix return type declarations 2019-08-26 09:52:58 +02:00
Nicolas Grekas
5f9aaa743c [Cache] fix return type declarations 2019-08-26 09:52:58 +02:00
Alexander M. Turek
5072cfc7f8 [Serializer] fix return type declarations 2019-08-26 09:52:58 +02:00
Alexander M. Turek
70feaa407e [Translation] fix return type declarations 2019-08-26 09:52:58 +02:00
Alexander M. Turek
ca1fad471e [DI] fix return type declarations 2019-08-26 09:52:58 +02:00
Alexander M. Turek
9c63be489e [Config] fix return type declarations 2019-08-26 09:52:57 +02:00
Nicolas Grekas
05fe553666 [HttpKernel] Fix return type declarations 2019-08-26 09:50:50 +02:00
Alexander M. Turek
e0d79f71ed [Security] Fix return type declarations 2019-08-26 09:50:50 +02:00
Alexander M. Turek
c1b7118d7c [Routing] Fix return type declarations 2019-08-26 09:50:50 +02:00
Nicolas Grekas
ef5ead0005 [HttpFoundation] fix return type declarations 2019-08-26 09:50:50 +02:00
Fabien Potencier
6c9b87c5ea feature #33323 [TwigBridge] Throw an exception when one uses email as a context variable in a TemplatedEmail (fabpot)
This PR was merged into the 4.4 branch.

Discussion
----------

[TwigBridge] Throw an exception when one uses email as a context variable in a TemplatedEmail

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | refs #33310
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against branch 4.4.
 - Legacy code removals go to the master branch.
-->

Commits
-------

0cc705bf7d [TwigBridge] Throw an exception when one uses email as a context variable in a TemplatedEmail
2019-08-26 08:19:52 +02:00
Fabien Potencier
0cc705bf7d [TwigBridge] Throw an exception when one uses email as a context variable in a TemplatedEmail 2019-08-25 09:13:08 +02:00
Fabien Potencier
aa81e2721a minor #33314 [DomCrawler] Fix @throws (dunglas)
This PR was merged into the 4.3 branch.

Discussion
----------

[DomCrawler] Fix @throws

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | n/a

A `LogicException` is thrown, not a `RuntimeException`.

Commits
-------

a414c0323a [DomCrawler] Fix @throws
2019-08-25 09:01:30 +02:00
Fabien Potencier
610a4e978f feature #33308 [SecurityGuard] Deprecate returning non-boolean values from checkCredentials() (derrabus)
This PR was merged into the 4.4 branch.

Discussion
----------

[SecurityGuard] Deprecate returning non-boolean values from checkCredentials()

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | prepares #33228
| License       | MIT
| Doc PR        | TODO

This PR suggests to deprecate implementations of `Symfony\Component\Security\Guard\AuthenticatorInterface::checkCredentials()` that return non-boolean values. This will allow us to add `bool` as return type declaration in the future.

https://github.com/nicolas-grekas/symfony/pull/26#discussion_r317084918

/cc @nicolas-grekas @weaverryan

Commits
-------

a0ca3afeca Deprecate returning non-boolean values from checkCredentials().
2019-08-25 08:59:38 +02:00
Fabien Potencier
5b3028ad0d minor #33318 [PhpUnitBridge] Bump SYMFONY_PHPUNIT_VERSION (ro0NL)
This PR was merged into the 4.4 branch.

Discussion
----------

[PhpUnitBridge] Bump SYMFONY_PHPUNIT_VERSION

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

👋 here we are again :)

i was wondering... cant we just install the latest minor by default, thus `SYMFONY_PHPUNIT_VERSION=8`? There should be no BC breaks, and would reduce the maintenance to one major bump, once a year ... isnt it? 🤔

Commits
-------

9cbd0e8809 [PhpUnitBridge] Bump SYMFONY_PHPUNIT_VERSION
2019-08-25 08:56:47 +02:00
Yonel Ceruto
85a484ce0f minor #33321 [ErrorRenderer] Fix closing tag in logs table (yceruto)
This PR was merged into the 4.4 branch.

Discussion
----------

[ErrorRenderer] Fix closing tag in logs table

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes (visual)
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

96a81bd Fix closing tag in logs table
2019-08-24 19:37:20 -04:00
Yonel Ceruto
96a81bd7ad Fix closing tag in logs table 2019-08-24 19:32:44 -04:00
Roland Franssen
9cbd0e8809
[PhpUnitBridge] Bump SYMFONY_PHPUNIT_VERSION 2019-08-24 11:13:20 +02:00
Kévin Dunglas
a414c0323a
[DomCrawler] Fix @throws 2019-08-24 00:39:04 +02:00
Yonel Ceruto
dc8d470752 feature #33217 [FrameworkBundle][DX] Improving the redirect config when using RedirectController (yceruto)
This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle][DX] Improving the redirect config when using RedirectController

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/pull/12189

follow-up https://github.com/symfony/symfony/pull/24637

**Before:**
```yaml
# config/routes.yaml
doc_shortcut:
    path: /doc
    controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
    defaults:
        route: 'doc_page'

legacy_doc:
    path: /legacy/doc
    controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction
    defaults:
        path: 'https://legacy.example.com/doc'
```

**After:**
```yaml
# config/routes.yaml
doc_shortcut:
    path: /doc
    controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController
    defaults:
        route: 'doc_page'

legacy_doc:
    path: /legacy/doc
    controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController
    defaults:
        path: 'https://legacy.example.com/doc'
```

See more before/after configs (XML, PHP) in doc PR https://github.com/symfony/symfony-docs/pull/12189

Commits
-------

0ebb469 Improving redirect config when using RedirectController
2019-08-23 17:47:48 -04:00
Yonel Ceruto
0ebb469269 Improving redirect config when using RedirectController 2019-08-23 17:44:26 -04:00