coolgoose / larastan-legacy
Larastan Legacy 1.x - Unmaintained fork to fix composer dependency
Fund package maintenance!
nunomaduro
canvural
Patreon
www.paypal.com/paypalme/enunomaduro
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 410
Type:phpstan-extension
Requires
- php: ^8.0.2
- ext-json: *
- illuminate/console: ^9.52.16 || ^10.28.0 || ^11.0
- illuminate/container: ^9.52.16 || ^10.28.0 || ^11.0
- illuminate/contracts: ^9.52.16 || ^10.28.0 || ^11.0
- illuminate/database: ^9.52.16 || ^10.28.0 || ^11.0
- illuminate/http: ^9.52.16 || ^10.28.0 || ^11.0
- illuminate/pipeline: ^9.52.16 || ^10.28.0 || ^11.0
- illuminate/support: ^9.52.16 || ^10.28.0 || ^11.0
- phpmyadmin/sql-parser: ^5.9.0
- phpstan/phpstan: ^1.10.66
Requires (Dev)
- doctrine/coding-standard: ^12.0
- nikic/php-parser: ^4.19.1
- orchestra/canvas: ^7.11.1 || ^8.11.0 || ^9.0.2
- orchestra/testbench: ^7.33.0 || ^8.13.0 || ^9.0.3
- phpunit/phpunit: ^9.6.13 || ^10.5.16
Suggests
- orchestra/testbench: Using Larastan for analysing a package needs Testbench
- 2.x-dev
- v2.9.5
- v2.9.4
- v2.9.3
- v2.9.2
- v2.9.1
- v2.9.0
- v2.8.1
- v2.8.0
- v2.7.0
- v2.6.5
- v2.6.4
- v2.6.3
- v2.6.2
- v2.6.1
- v2.6.0
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.9
- 2.2.8
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- v2.2.0
- v2.1.12
- v2.1.11
- v2.1.10
- v2.1.9
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.1
- 2.0.0
- 1.x-dev
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- v0.7.15
- v0.7.14
- v0.7.13
- v0.7.12
- v0.7.11
- v0.7.10
- v0.7.9
- v0.7.8
- v0.7.7
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.13
- v0.6.12
- v0.6.11
- v0.6.10
- v0.6.9
- v0.6.8
- v0.6.7
- v0.6.6
- v0.6.5
- v0.6.4
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.8
- v0.5.7
- v0.5.6
- v0.5.5
- v0.5.4
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.21
- v0.3.20
- v0.3.19
- v0.3.18
- v0.3.17
- v0.3.16
- v0.3.15
- v0.3.14
- v0.3.13
- v0.3.12
- v0.3.11
- v0.3.10
- v0.3.9
- v0.3.8
- v0.3.7
- v0.3.6
- v0.3.5
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.12
- v0.2.11
- v0.2.10
- v0.2.9
- v0.2.8
- v0.2.7
- v0.2.6
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.10
- v0.1.9
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-patch-1
- dev-unused-translations
This package is auto-updated.
Last update: 2024-10-22 14:41:51 UTC
README
Note, this is just a workaround release for removing the direct composer dependency for the legacy unmaintained 1.x version. see composer/composer#11940
⚗️ About Larastan
Larastan was created by Can Vural and Nuno Maduro, got artwork designed by @Caneco, is maintained by Can Vural, Nuno Maduro, and Viktor Szépe, and is a PHPStan wrapper for Laravel. Larastan focuses on finding errors in your code. It catches whole classes of bugs even before you write tests for the code.
- Adds static typing to Laravel to improve developer productivity and code quality
- Supports most of Laravel's beautiful magic
- Discovers bugs in your code
While by definition, "static analysis" doesn't load any of your application's code. Larastan boots your application's container, so it can resolve types that are only possible to compute at runtime. That's why we use the term "code analysis" instead of "static analysis".
✨ Getting Started In 3 Steps
Requires:
1: First, you may use Composer to install Larastan as a development dependency into your Laravel project:
composer require nunomaduro/larastan:^1.0 --dev
Using Larastan for analysing Laravel packages? You may need to install
orchestra/testbench
.
2: Then, create a phpstan.neon
or phpstan.neon.dist
file in the root of your application. It might look like this:
includes:
- ./vendor/nunomaduro/larastan/extension.neon
parameters:
paths:
- app
# The level 9 is the highest level
level: 5
ignoreErrors:
- '#Unsafe usage of new static#'
excludePaths:
- ./*/*/FileToBeExcluded.php
checkMissingIterableValueType: false
For all available options, please take a look at the PHPStan documentation: https://phpstan.org/config-reference
3: Finally, you may start analyzing your code using the phpstan console command:
./vendor/bin/phpstan analyse
If you are getting the error Allowed memory size exhausted
, then you can use the --memory-limit
option fix the problem:
./vendor/bin/phpstan analyse --memory-limit=2G
Ignoring errors
Ignoring a specific error can be done either with a php comment or in the configuration file:
// @phpstan-ignore-next-line $test->badMethod(); $test->badMethod(); // @phpstan-ignore-line
When ignoring errors in PHPStan's configuration file, they are ignored by writing a regex based on error messages:
parameters: ignoreErrors: - '#Call to an undefined method .*badMethod\(\)#'
Baseline file
In older codebases it might be hard to spend the time fixing all the code to pass a high PHPStan Level.
To get around this a baseline file can be generated. The baseline file will create a configuration file with all of the current errors, so new code can be written following a higher standard than the old code. (PHPStan Docs)
./vendor/bin/phpstan analyse --generate-baseline
Rules
A list of configurable rules specific to Laravel can be found here.
Custom PHPDoc types
A list of PHPDoc types specific to Larastan can be found here.
Custom PHPStan config parameters
A list of custom config parameters that you can use in your PHPStan config file can be found here.
Errors To Ignore
Some parts of Laravel are currently too magical for Larastan/PHPStan to understand. We listed common errors to ignore, add them as needed
👊🏻 Contributing
Thank you for considering contributing to Larastan. All the contribution guidelines are mentioned here.
You can have a look at the CHANGELOG for constant updates & detailed information about the changes. You can also follow the Twitter account for the latest announcements or just come say hi!: @enunomaduro, @can__vural.
❤️ Support The Development
Do you like this project? Support it by donating
📖 License
Larastan is an open-sourced software licensed under the MIT license.