Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[ErrorHandler] Turn return-type annotations into deprecations by default + add mode to turn them into native types#42623

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedAug 18, 2021
edited
Loading

QA
Branch?5.4
Bug fix?no
New feature?yes
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

Leverages#42149

We need extensive doc on the topic for sure, a whole new chapter.

DebugClassLoader allows patching an app or a lib by going through these steps:

  • requiresymfony/error-handler if not already there
  • runcomposer install -q --optimize-autoloader
  • copy/paste the below script to the root of the app/lib, inpatch-types.php
  • run the script withSYMFONY_PATCH_TYPE_DECLARATIONS='force=phpdoc' php patch-types.php

SYMFONY_PATCH_TYPE_DECLARATIONS can be set to:

  • 'force=phpdoc' to copy@return annotations from parent classes, to express that the next major version of that lib is going to add a native return types;
  • 'force=1' to turn@return annotations into native return types, but only on tests/private/final/internal methods;
  • 'force=2' to turn@return annotations into native return types, for all possible methods.
<?phpif (false ===getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {echo"Please define the SYMFONY_PATCH_TYPE_DECLARATIONS env var when running this script.\n";exit(1);}$loader =require__DIR__.'/vendor/autoload.php';Symfony\Component\ErrorHandler\DebugClassLoader::enable();foreach ($loader->getClassMap()as$class =>$file) {switch (true) {casefalse !==strpos($file =realpath($file),'/vendor/'):casefalse !==strpos($file,'/src/path-to-exclude/'):// add as many as requiredcontinue2;    }class_exists($class);}Symfony\Component\ErrorHandler\DebugClassLoader::checkClasses();

@nicolas-grekasnicolas-grekas added this to the5.4 milestoneAug 18, 2021
@nicolas-grekasnicolas-grekasforce-pushed theenable-debugclassloader branch 2 times, most recently from87fa7a8 tof6bc9adCompareAugust 18, 2021 12:24
@nicolas-grekasnicolas-grekas changed the title[ErrorHandler] make DebugClassLoader throw deprecations on missing return types[ErrorHandler] Turn return-type annotations into deprecations by default, add mode to turn them into native typesAug 18, 2021
@nicolas-grekasnicolas-grekas changed the title[ErrorHandler] Turn return-type annotations into deprecations by default, add mode to turn them into native types[ErrorHandler] Turn return-type annotations into deprecations by default + add mode to turn them into native typesAug 18, 2021
@nicolas-grekasnicolas-grekasforce-pushed theenable-debugclassloader branch 3 times, most recently from80c5ef4 to1269f85CompareAugust 25, 2021 08:29
@nicolas-grekas
Copy link
MemberAuthor

/cc @symfony/mergers reviews pending 🙏

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark left review comments

@derrabusderrabusderrabus approved these changes

@chalasrchalasrchalasr approved these changes

@ycerutoycerutoAwaiting requested review from ycerutoyceruto is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

5 participants

@nicolas-grekas@OskarStark@derrabus@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp