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

Throw an error if phpcsutils is not available #177

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

Merged
sirbrillig merged 3 commits into master from add-exception-if-no-phpcsutils
May 16, 2020

Conversation

@sirbrillig
Copy link
Owner

@sirbrillig sirbrillig commented May 16, 2020
edited
Loading

As part of an effort to make sure that the dependencies are correctly installed, this adds PHPCSUtils as a dependency to the sniff. Without this change, it's possible to use VariableAnalysis functionally without phpcsutils until we hit a code path that needs it. In the interest of "fail fast" and giving a slightly more helpful error, this will fail immediately if the library is not there.

ERROR: Referenced sniff "PHPCSUtils" does not exist
Run "phpcs --help" for usage information

This also updates the README to include installation instructions for PHPCSUtils.

Copy link
Owner Author

Related to #160

Copy link
Collaborator

jrfnl commented May 16, 2020

@sirbrillig I see what you are trying to do here, but am not sure this is really necessary. Updating the installation instructions in the Readme should be sufficient, especially if that would include saying that stand-alone installation, while still possible, is no longer supported (only Composer install supported).

If you do want to get an error & fail fast, you could simplify this, by just adding <rule ref="PHPCSUtils"/> to the ruleset.
When PHPCS encounters that and PHPCSUtils is not installed, it should automatically throw an error, so no custom logic needed.

Copy link
Collaborator

jrfnl commented May 16, 2020

Oh and including the standard using a path to the ruleset <rule ref="./vendor/etc/VariableAnalysis/ruleset.xml"/> instead of by name <rule ref="VariableAnalysis"/> is also no longer supported then, but seriously, that functionality is buggy to begin with, so why anyone would ever use that.... 🙊

@sirbrillig sirbrillig force-pushed the add-exception-if-no-phpcsutils branch from da7c099 to f61e31f Compare May 16, 2020 20:06
@sirbrillig sirbrillig changed the title (削除) Throw a MissingDependencyException if phpcsutils is not available (削除ここまで) (追記) Throw an error if phpcsutils is not available (追記ここまで) May 16, 2020
Copy link
Owner Author

Thanks for the hint. That's nicer really because it shows the error to the user rather than logging it in the PHP logs. It would be nice if there was a way to make it more explicit (even just "this is required by VariableAnalysis" or something) but that's fine. I've updated the branch and (finally) updated the README.

jrfnl reacted with thumbs up emoji

Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com>
@sirbrillig sirbrillig merged commit 5f65b15 into master May 16, 2020
@sirbrillig sirbrillig deleted the add-exception-if-no-phpcsutils branch May 16, 2020 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jrfnl jrfnl jrfnl left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /