-
Notifications
You must be signed in to change notification settings - Fork 30
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
Travis: add task to lint the PHP files against all supported versions #65
Conversation
* Includes installing the [PHP-Parallel-Lint](https://github.com/JakubOnderka/PHP-Parallel-Lint) package to allow for fast linting and comprehensive error reporting. * Includes installing the PHP console highlighter to enable syntax highlighting of the reporting by PHP-Parallel-Lint. * Includes adding a Composer script to run the command easily with the correct command-line arguments. Note: using `@php` will make sure that the script is triggered with the same PHP version as Composer is using (if different from the system default PHP version). Note: calling the actual `parallel-lint` script directly instead of via the `vendor/bin` will allow for the script to run cross-platform as otherwise devs on Windows may run into errors.
Thanks. Again. I will take some more time to merge this because I'm not familiar with the tool, and want to look at it first. |
@gmazzap Alternatively a pure PHP CLI implementation can be used, but in my experience this tool gives more user-friendly results. On a practical note: I'm lining up the other CI/QA PRs, but they need to be pulled "in order" as they would all conflict if I pulled them at the same time. |
@jrfnl I just want to have a quick look at the tool before adding it to the requirements, I don't feel super comfortable in adding things I never heard of :) Regarding the practical note: whichever works best for you. If it helps, I expect to merge this no earlier than tomorrow |
@gmazzap I'll just pull them in the order they are in, in that case. A few days here or there is not what I'm worried about. PRs which are open for months is ;-) |
In all honesty, I'm not very keen to introduce it. I'm very careful in adding dependencies, and this PR will introduce 3 new dependencies to do something that I don't feel is so essential. The codebase is very well covered in tests, all files are loaded in tests, and I will not allow new files that have at least one test. Meaning that there's no way for a file with the wrong syntax to land in the codebase while the test suite passes. Because syntax is checked when files are loaded, and not when executed, even if something is never used (so not covered) in tests PHP will raise an exception / fatal error in case of the wrong syntax. On top of that, I just assume that all people working on the codebase don't do that on a "plain" text editor, but in an IDE or at least in a text editor that has PHP syntax highlight and linting integrated. So the proposed tools, in my opinion, would be of some benefit only in very edge cases, and even in those cases, when tests are run, PHP will raise a syntax error, with a message that far to be perfect, is surely easier to google. I'm not closing this right away, to see if @jrfnl or anyone else has arguments to change my opinion. |
As I said above, a pure bash/PHP implementation for this check is also possible. That would mean no dependencies would be introduced.
Until only yesterday, test coverage was not checked, nor published, and this proposal was from before that time...
IDEs only lint against one particular PHP version, either the system default or whatever version you have configured the IDE to work with.
Parallel lint will show the same error message, but will also show you the line on which the error is encountered. As I said, just a faster and more user-friendly way than the PHP native linting.
Close if you like, but in that case, please have another look at #63 which you gave a 👍 and leave a comment on which things you think is a good idea. I've got plenty other things to do, so please don't waste my time. |
The point is that I don't think that checking for syntax error is necessary at all.
Coverage is competely unrelated. As said above, it does not matter if a piece of code is excuted or not (in theory coverage could be 0%), PHP checks syntax at parse time, so even if code that contains syntax errors is never executed, the syntax errors are raised. That means that is possible to trigger a fatal syntax error just It means that when PHP unit tests run on Travis, if any of the files contain a syntax error, Travis build will fail because of that, and that before your (awesome) work from yesterday. This is why, again, I don't think that a separate check for syntax is required: it is implicitly included in the unit tests. This of course is true if all the files are required, and it is my responsibility to make sure that no new file is added without it being at least required during tests.
Yes, that library has nice errors compared to PHP, but I think that IDEs do event a better job, and I don't think that during development people will keep running Still, there might be cases is which this could be useful to someone in some context, but it is a so edge case IMO that I don't think it is worth to be considered.
Will do. And thanks a ton for your work and the time you're spending on this project. |
Well, to me it was as I didn't know that you'd made sure that all files were being tested and I wasn't going to verify this manually ;-) |
Note: using
@php
will make sure that the script is triggered with the same PHP version as Composer is using (if different from the system default PHP version).Note: calling the actual
parallel-lint
script directly instead of via thevendor/bin
will allow for the script to run cross-platform as otherwise devs on Windows may run into errors.Related to #63