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

Glob style pathspecs are not handled correctly, and no warning is given #7

Closed
j13k opened this issue Mar 27, 2018 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@j13k
Copy link
Owner

j13k commented Mar 27, 2018

Problem

As reported in feature request #3 and lmc-eu/php-coding-standard#8, there is an issue with glob style path specs (e.g. *.yml) not being handled correctly—only the last file in the set of filenames is parsed, but this is not clear in the output. This is confusing for users and could result in false reports.

Proposed Fix

Until the tool is upgraded to handle multiple files, it should be patched to reject glob style path specs and warn the user. The documentation should also clarify this.

Analysis

It seems $_SERVER['argv'] expands globs automatically, behaviour which was unexpected on my part. The script loops over the values of argv, assigning path values to a scalar argPath variable, which is then parsed. When multiple paths are specified (as in case of the expanded glob file set), the value of argPath ultimately rests on the last filename in the list.

This scratch script illustrates the issue using the Symfony Yaml component test fixture files as an example:

<?php print var_export($_SERVER['argv']) . PHP_EOL;

The script output demonstrates the implicit glob expansion:

$ php php-argv-test.php vendor/symfony/yaml/Tests/Fixtures/*.yml
array (
  0 => 'php-argv-test.php',
  1 => 'vendor/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml',
  2 => 'vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml',
... lines deleted ...
  28 => 'vendor/symfony/yaml/Tests/Fixtures/sfTests.yml',
  29 => 'vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml',
)

In the case of this path spec, only the last file, vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml, is processed.

@j13k j13k added the bug label Mar 27, 2018
@j13k j13k added this to the 1.1.3 milestone Mar 27, 2018
j13k added a commit that referenced this issue Mar 27, 2018
j13k added a commit that referenced this issue Mar 27, 2018
j13k added a commit that referenced this issue Mar 27, 2018
@j13k
Copy link
Owner Author

j13k commented Mar 27, 2018

Fixed in f677709.

@j13k j13k closed this as completed Mar 27, 2018
@j13k j13k self-assigned this Dec 10, 2020
@j13k j13k moved this to Done 2018 in j13k/yaml-lint May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done 2018
Development

No branches or pull requests

1 participant