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

[Yaml] report deprecations when linting YAML files #22274

Merged
merged 1 commit into from Apr 5, 2017

Conversation

Projects
None yet
5 participants
@xabbuh
Copy link
Member

commented Apr 4, 2017

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

In a project I frequently discovered usages of deprecated YAML formats. I first wanted to set up a build step that would lint all YAML files found in that project to be able to report it inside the CI. While doing so I noticed that the lint command was ignoring all deprecations after all. I suggest that catch all deprecations triggered by the YAML components and turn them into reported errors here. If we think that this could be seen as misbehaviour as the Symfony YAML parser is still able to handle these files properly, we could think about adding an additional option to the command that would turn on the deprecation handling.

@xabbuh xabbuh force-pushed the xabbuh:lint-deprecations branch from 63221ac to f0d27ae Apr 4, 2017

@xabbuh xabbuh added this to the 3.4 milestone Apr 4, 2017

@xabbuh xabbuh force-pushed the xabbuh:lint-deprecations branch from f0d27ae to 56ac0a3 Apr 4, 2017

set_error_handler(function ($level, $message) {
if (E_USER_DEPRECATED === $level) {
throw new ParseException($message);
}

This comment has been minimized.

Copy link
@stof

stof Apr 4, 2017

Member

any other errors should be forwarded to the normal error handler instead of being ignored

This comment has been minimized.

Copy link
@xabbuh

xabbuh Apr 4, 2017

Author Member

fixed

@@ -102,10 +102,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
private function validate($content, $file = null)
{
$prevErrorHandler = set_error_handler(function ($level, $message, $file, $line, $context) use (&$prevErrorHandler) {

This comment has been minimized.

Copy link
@nicolas-grekas

nicolas-grekas Apr 5, 2017

Member

$context is deprecated in php 7.2, let's remove it

This comment has been minimized.

Copy link
@xabbuh

xabbuh Apr 5, 2017

Author Member

done

@xabbuh xabbuh force-pushed the xabbuh:lint-deprecations branch from ed07aa7 to 9b4206f Apr 5, 2017

@stof

stof approved these changes Apr 5, 2017

Copy link
Member

left a comment

👍

@fabpot

This comment has been minimized.

Copy link
Member

commented Apr 5, 2017

Thank you @xabbuh.

@fabpot fabpot merged commit 9b4206f into symfony:master Apr 5, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Apr 5, 2017

feature #22274 [Yaml] report deprecations when linting YAML files (xa…
…bbuh)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[Yaml] report deprecations when linting YAML files

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

In a project I frequently discovered usages of deprecated YAML formats. I first wanted to set up a build step that would lint all YAML files found in that project to be able to report it inside the CI. While doing so I noticed that the lint command was ignoring all deprecations after all. I suggest that catch all deprecations triggered by the YAML components and turn them into reported errors here. If we think that this could be seen as misbehaviour as the Symfony YAML parser is still able to handle these files properly, we could think about adding an additional option to the command that would turn on the deprecation handling.

Commits
-------

9b4206f report deprecations when linting YAML files

@xabbuh xabbuh deleted the xabbuh:lint-deprecations branch Apr 5, 2017

@fabpot fabpot referenced this pull request May 1, 2017

Merged

Release v3.3.0-BETA1 #22603

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.