-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add EditorConfig and PHPStan #61
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 tasks
Enforces minimal coding styles to match existing coding styles inspired by WordPress' own styles. Changed: - Replaced inconsistent indentation in `RemoteFilesystem`. - Removed colon in pull request template to match other titles.
As well as Composer to analyze source and catch potential issues. Required: - composer/composer ^1.0 or ^2.0 - phpstan/phpstan ^1.10 Usage: ```shell composer lint:phpstan -- --xdebug ```
Changed: - Throw `InvalidArgumentException` instead of `UnexpectedValueException` when dealing with an unsupported package in Ninja Forms, PublishPress Pro, and WPML. - Throw `UnexpectedValueException` if the decoded/unserialized API response is not an array. - Added PHPDoc tags to document exceptions. - Fixed issues reported by PHPStan.
Changed: - Added protected method `request()` to aggregate the execution of the request, handling of the response, and closing of the cURL handler. - Throw `UnexpectedValueException` if the request failed or if the response is invalid or empty. - Fixed issues reported by PHPStan.
mcaskill
force-pushed
the
feature/linting
branch
from
July 11, 2024 22:15
9b27a98
to
d5ae98d
Compare
Based on the PHP version and installed package versions. Added conditionally included baselines for PHP 5–7 and 8+, Composer 1 and 2, Dotenv 3–5. This conditional functionality can be greatly reduced if we drop support for older versions of PHP, Composer, and other dependencies. To resolve these conditional baselines, we have to replace the initial data of `Composer\InstalledVersions` which contains PHPStan's dependencies, since the context is its PHAR. To accomplish this, we have to retrieve the contents of the project's installed dependencies from either: 1. `vendor/composer/installed.php` — Composer v2 PHP format. 2. `vendor/composer/installed.json` — Either Composer v1 or v2 JSON format. The JSON format is tricky because it changes drastically between Composer v1 and v2 and the v2 PHP format. Both JSON formats must be remapped to the PHP format expected by `InstalledVersions`. If the project's installed dependencies cannot be loaded, this file returns only the PHP baselines. If the project's installed dependencies can be loaded, the extra baselines are resolved and the initial data of `InstalledVersions` is restored.
Accidentally marked the wrong pull request on the upstream repository instead of the fork 🤦♂️ |
mcaskill
added a commit
to wp-jazz/composer-wp-pro-plugins
that referenced
this pull request
Jul 13, 2024
From from 'mcaskill/feature/linting': Add EditorConfig and PHPStan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
Description
Follow-up to #59 and fork of #58.
Depends on #58 being merged first.
Added an EditorConfig ruleset to enforce tabs for PHP files and spaces for JSON, Markdown, NEON, YML, and XML files. This should help avoid accidental mixing of tabs if one's IDE supports this feature.
Added PHPStan dependency to help finds bugs and logic flaws. Given that tests are absent and not so simple to write given the proprietary and expensive nature of its target WP plugins.
PHPStan's situation is a little complicated given this plugin supports multiple versions of different packages (notably Composer and vlucas/phpdotenv). PHPStan can't tell that and reports errors for whichever version is not installed. To resolve this, I've introduced a way to conditionally include different baselines based on what is installed in order to hide "errors" from versions not installed.
This conditional functionality can be greatly reduced if we drop support for older versions of PHP, Composer, and other dependencies.
How has this been tested?
Types of changes