Git hooks to auto-run phpcbf (Code Beautifer) on commits
GitHub Actions to auto-run phpcbf on pushes to master and to validate PhpStan
README badges to indicate code style and PhpStan level
When this is merged, it will automatically run on the existing code. Pending PRs will probably have to rebase to master before merging.
Most other CodeSniffer rulesets are based on PSR-12, so this is just a baseline to get started. PHPStan levels go up to 9, so 6 is a moderate compromise to aim for for now.
phpcs:
FILE: /Users/brianhenry/Sites/monerophp/src/mnemonic.php
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 19 ERRORS AND 2 WARNINGS AFFECTING 17 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 | WARNING | A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but
| | should not do both. The first symbol is defined on line 37 and the first side effect is on line 302.
37 | ERROR | Class name "mnemonic" is not in PascalCase format
42 | ERROR | Visibility must be declared on method "checksum"
61 | ERROR | Method name "mnemonic::validate_checksum" is not in camel caps format
159 | WARNING | Line exceeds 120 characters; contains 173 characters
277 | ERROR | Each class must be in a file by itself
302 | ERROR | Closing brace must not be followed by any comment or statement on the same line
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
phpstan analyse:
------ --------------------------------------------------------------------------------------------------------------------------
Line mnemonic.php
------ --------------------------------------------------------------------------------------------------------------------------
42 Method MoneroIntegrations\MoneroPhp\mnemonic::checksum() has no return type specified.
42 Method MoneroIntegrations\MoneroPhp\mnemonic::checksum() has parameter $prefix_len with no type specified.
45 Parameter #2 $offset of function array_slice expects int, null given.
72 Parameter #3 $pad_string of function str_pad expects string, int given.
301 Method MoneroIntegrations\MoneroPhp\wordset::words() return type has no value type specified in iterable type array.
💡 See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type
------ --------------------------------------------------------------------------------------------------------------------------
Run
composer lint
to run manually. Automatically runs locally on commits. Automatically runs on GitHub on pushes.Adds:
phpcbf
(Code Beautifer) on commitsphpcbf
on pushes to master and to validate PhpStanWhen this is merged, it will automatically run on the existing code. Pending PRs will probably have to rebase to master before merging.
Most other CodeSniffer rulesets are based on PSR-12, so this is just a baseline to get started. PHPStan levels go up to 9, so 6 is a moderate compromise to aim for for now.
phpcs
:phpstan analyse
:Fixes #84