Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 87fa7a8

Browse filesBrowse files
[ErrorHandler] Turn return-type annotations into deprecations by default, add mode to turn them into native types
1 parent 1a84d3d commit 87fa7a8
Copy full SHA for 87fa7a8

File tree

4 files changed

+11
-5
lines changed
Filter options

4 files changed

+11
-5
lines changed

‎.github/patch-types.php

Copy file name to clipboardExpand all lines: .github/patch-types.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
switch (true) {
1616
case false !== strpos($file = realpath($file), '/vendor/'):
1717
case false !== strpos($file, '/src/Symfony/Bridge/PhpUnit/'):
18-
case false !== strpos($file, '/Attribute/'):
1918
case false !== strpos($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'):
2019
case false !== strpos($file, '/src/Symfony/Component/Cache/Tests/Fixtures/DriverWrapper.php'):
2120
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadFileName.php'):

‎.github/workflows/unit-tests.yml

Copy file name to clipboardExpand all lines: .github/workflows/unit-tests.yml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ jobs:
139139
if: "${{ matrix.php == '8.0' && ! matrix.mode }}"
140140
run: |
141141
sed -i 's/"\*\*\/Tests\/"//' composer.json
142+
git add .
142143
composer install -q --optimize-autoloader
143144
SYMFONY_PATCH_TYPE_DECLARATIONS='force=1&php=7.2' php .github/patch-types.php
144145
SYMFONY_PATCH_TYPE_DECLARATIONS='force=1&php=7.2' php .github/patch-types.php # ensure the script is idempotent

‎src/Symfony/Component/ErrorHandler/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
5.4
5+
---
6+
7+
* make `DebugClassLoader` trigger deprecation notices on missing return types
8+
* add `SYMFONY_PATCH_TYPE_DECLARATIONS='force=2'` mode to `DebugClassLoader` to turn annotations into native return types
9+
410
5.2.0
511
-----
612

‎src/Symfony/Component/ErrorHandler/DebugClassLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/DebugClassLoader.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@
3434
* which is a url-encoded array with the follow parameters:
3535
* - "force": any value enables deprecation notices - can be any of:
3636
* - "phpdoc" to patch only docblock annotations
37-
* - "object" to turn union types to the "object" type when possible (not recommended)
38-
* - "1" to add all possible return types including magic methods
39-
* - "0" to add possible return types excluding magic methods
37+
* - "2" to add all possible return types
38+
* - "1" to add return types but only to tests/final/internal/private methods
4039
* - "php": the target version of PHP - e.g. "7.1" doesn't generate "object" types
4140
* - "deprecations": "1" to trigger a deprecation notice when a child class misses a
4241
* return type while the parent declares an "@return" annotation
@@ -534,7 +533,8 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
534533
$this->patchTypes['force'] = $forcePatchTypes ?: 'docblock';
535534
}
536535

537-
$canAddReturnType = false !== strpos($refl->getFileName(), \DIRECTORY_SEPARATOR.'Tests'.\DIRECTORY_SEPARATOR)
536+
$canAddReturnType = 2 === (int) $forcePatchTypes
537+
|| false !== stripos($method->getFileName(), \DIRECTORY_SEPARATOR.'Tests'.\DIRECTORY_SEPARATOR)
538538
|| $refl->isFinal()
539539
|| $method->isFinal()
540540
|| $method->isPrivate()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.