Skip to content

Fixer incorrectly handles filepaths with repeated dir names #1267

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

Closed
orx0r opened this issue Jan 11, 2017 · 1 comment
Closed

Fixer incorrectly handles filepaths with repeated dir names #1267

orx0r opened this issue Jan 11, 2017 · 1 comment

Comments

@orx0r
Copy link
Contributor

orx0r commented Jan 11, 2017

Fixer incorrectly handles filepath, e.g.:

For example, if filePath is /app/path/app/file.php and cwd is /app/, expected filepath should be path/app/file.php
But in fact, filepath became wrong - pathfile.php

Because str_replace replaces all occurrences in target filepath:
https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Fixer.php#L246

$cwd      = getcwd().DIRECTORY_SEPARATOR;
$filename = str_replace($cwd, '', $filePath);
orx0r added a commit to orx0r/PHP_CodeSniffer that referenced this issue Jan 11, 2017
orx0r added a commit to orx0r/PHP_CodeSniffer that referenced this issue Jan 11, 2017
orx0r added a commit to orx0r/PHP_CodeSniffer that referenced this issue Jan 11, 2017
@orx0r
Copy link
Contributor Author

orx0r commented Jan 11, 2017

PR: #1269

orx0r added a commit to orx0r/PHP_CodeSniffer that referenced this issue Jan 12, 2017
orx0r added a commit to orx0r/PHP_CodeSniffer that referenced this issue Jan 12, 2017
@gsherwood gsherwood changed the title Fixer incorrectly handles filepath Fixer incorrectly handles filepaths with repeated dir names Jan 12, 2017
gsherwood added a commit that referenced this issue Jan 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants