Skip to content

Commit

Permalink
feat: enable PHPStan bleeding edge mode (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
COil authored Oct 4, 2024
1 parent c417e08 commit cea66d0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ cov-report: var/coverage/index.html ## Open the PHPUnit code coverage report (va

## —— Coding standards/lints ✨ ————————————————————————————————————————————————
stan: var/cache/dev/App_KernelDevDebugContainer.xml ## Run PHPStan
@vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vvv
@vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vv

# PHPStan needs the dev/debug cache
var/cache/dev/App_KernelDevDebugContainer.xml:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ These branches will be rebased after each release so they are always up to date.
## References 📚

* [A better ADR pattern for your Symfony controllers](https://www.strangebuzz.com/en/blog/a-better-adr-pattern-for-your-symfony-controllers) (strangebuzz.com) (coming soon)
* [You should be using PHPStans bleeding edge](https://backendtea.com/post/use-phpstan-bleeding-edge/) (backendtea.com)
* [A Good Naming Convention for Routes, Controllers and Templates?](https://jolicode.com/blog/a-good-naming-convention-for-routes-controllers-and-templates) (jolicode.com)
* [Front-end application development, Symfony-style(s)](https://dunglas.dev/2024/04/front-end-application-development-symfony-styles/) (dunglas.dev)
* [Front-end application development, Symfony-style(s)](https://dunglas.dev/2024/04/front-end-application-development-symfony-styles/) (dunglas.dev)
* [Automated Test Coverage Checks with Travis, PHPUnit for Github Pull Requests](https://ocramius.github.io/blog/automated-code-coverage-check-for-github-pull-requests-with-travis/) (ocramius.github.io)
* [Installing and using php-cs-fixer](https://www.strangebuzz.com/en/blog/installing-and-using-php-cs-fixer) (strangebuzz.com)
* [Castor, a journey across the sea of task runners](https://jolicode.com/blog/castor-a-journey-across-the-sea-of-task-runners) (jolicode.com)
Expand Down
8 changes: 4 additions & 4 deletions bin/coverage-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
declare(strict_types=1);

$inputFile = $argv[1];

if (!is_numeric($argv[2])) {
throw new InvalidArgumentException('An integer checked percentage must be given as second parameter');
}
$percentage = min(100, max(0, (int) $argv[2]));

if (!file_exists($inputFile)) {
throw new InvalidArgumentException('Invalid input file provided');
}

if (!is_int($percentage)) {
throw new InvalidArgumentException('An integer checked percentage must be given as second parameter');
}

try {
@$xml = new SimpleXMLElement((string) file_get_contents($inputFile));
} catch (Exception) {
Expand Down
2 changes: 1 addition & 1 deletion castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function stan(): int
);
}

return exit_code('vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vvv', quiet: false);
return exit_code('vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vv', quiet: false);
}

#[AsTask(namespace: 'cs', description: 'Fix PHP files with php-cs-fixer (ignore PHP 8.2 warning)', aliases: ['fix-php'])]
Expand Down
8 changes: 7 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# https://phpstan.org/config-reference#bleeding-edge
# https://phpstan.org/blog/what-is-bleeding-edge
# comment the two following lines if you don't want to use the bleedingEdge mode.
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon

# https://phpstan.org/config-reference
parameters:
# https://phpstan.org/config-reference#rule-level
Expand All @@ -14,4 +20,4 @@ parameters:
container_xml_path: var/cache/dev/App_KernelDevDebugContainer.xml
# https://phpstan.org/user-guide/ignoring-errors
ignoreErrors:
#- '#my_ignore_error_regexp_pattern#'
#- '#my_ignore_error_regexp_pattern#'
3 changes: 3 additions & 0 deletions src/Form/Type/RegisterForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Form\Type;

use App\Dto\RegisterFormDto;
use App\Enum\Fruit;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
Expand All @@ -18,6 +19,8 @@

/**
* @see RegisterFormDto
*
* @extends AbstractType<RegisterFormDto>
*/
final class RegisterForm extends AbstractType
{
Expand Down

0 comments on commit cea66d0

Please sign in to comment.