|
1 | 1 | <p align="center">
|
2 |
| - <img src="https://raw.githubusercontent.com/larastan/larastan/master/docs/logo.png" alt="Larastan Logo" width="300"> |
| 2 | + <img src="https://raw.githubusercontent.com/calebdw/larastan/master/docs/logo.png" alt="Larastan Logo" width="300"> |
3 | 3 | <br><br>
|
4 |
| - <img src="https://raw.githubusercontent.com/larastan/larastan/master/docs/example.png" alt="Larastan Example" height="300"> |
| 4 | + <img src="https://raw.githubusercontent.com/calebdw/larastan/master/docs/example.png" alt="Larastan Example" height="300"> |
5 | 5 | </p>
|
6 | 6 |
|
7 | 7 | <p align="center">
|
8 |
| - <a href="https://github.com/larastan/larastan/actions"><img src="https://github.com/larastan/larastan/actions/workflows/tests.yml/badge.svg" alt="Build Status"></a> |
9 |
| - <a href="https://packagist.org/packages/larastan/larastan/stats"><img src="https://poser.pugx.org/larastan/larastan/d/total.svg" alt="Total Downloads"></a> |
10 |
| - <a href="https://packagist.org/packages/larastan/larastan"><img src="https://poser.pugx.org/larastan/larastan/v/stable.svg" alt="Latest Version"></a> |
11 |
| - <a href="https://github.com/larastan/larastan/blob/master/LICENSE.md"><img src="https://poser.pugx.org/larastan/larastan/license.svg" alt="License"></a> |
| 8 | + <a href="https://github.com/calebdw/larastan/actions"><img src="https://github.com/calebdw/larastan/actions/workflows/tests.yml/badge.svg" alt="Test Results"></a> |
| 9 | + <a href="https://packagist.org/packages/calebdw/larastan"><img src="https://img.shields.io/packagist/dt/calebdw/larastan.svg" alt="Total Downloads"></a> |
| 10 | + <a href="https://packagist.org/packages/calebdw/larastan"><img src="https://img.shields.io/packagist/v/calebdw/larastan.svg" alt="Latest Version"></a> |
| 11 | + <a href="https://github.com/calebdw/larastan/blob/master/LICENSE.md"><img src="https://img.shields.io/github/license/calebdw/larastan" alt="License"></a> |
12 | 12 | </p>
|
13 | 13 |
|
14 | 14 | ------
|
15 | 15 |
|
16 |
| -## ⚗️ About Larastan |
| 16 | +## ⚗️ About This Fork |
17 | 17 |
|
18 |
| -Larastan was created by [Can Vural](https://github.com/canvural) and [Nuno Maduro](https://github.com/nunomaduro), got artwork designed by [@Caneco](http://github.com/caneco), is maintained by [Can Vural](https://github.com/canvural) and [Viktor Szépe](https://github.com/szepeviktor), and is a [PHPStan](https://phpstan.org/) extension for Laravel. Larastan focuses on **finding errors in your code**. It catches whole classes of bugs even **before you write tests** for the code. |
| 18 | +Hello! 👋 |
19 | 19 |
|
20 |
| -- Adds static typing to Laravel to improve developer productivity and **code quality** |
21 |
| -- Supports most of [Laravel](https://laravel.com)'s **beautiful magic** |
22 |
| -- Discovers bugs in your code |
| 20 | +This is my fork of [larastan/larastan][larastan], which includes additional features and improvements that have been proposed but are not yet available in the upstream package. |
| 21 | +This fork is intended to provide the community with immediate access to these enhancements while maintaining compatibility with the upstream package. |
23 | 22 |
|
24 |
| -> 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". |
| 23 | +> For [Laravel Livewire][livewire] support, check out [larastan-livewire][larastan-livewire]! |
25 | 24 |
|
26 |
| -### Supported Laravel versions |
27 |
| -| Laravel Version | Larastan Version | |
28 |
| -|------------------|------------------| |
29 |
| -| < 9 | 1.x | |
30 |
| -| \> 9.0 && <11.15 | 2.x | |
31 |
| -| 11.15+ | 3.0+ | |
| 25 | +## 🔄 Changes and Upstream PRs |
32 | 26 |
|
33 |
| -## ✨ Getting Started In 3 Steps |
| 27 | +This fork includes the following changes and enhancements: |
34 | 28 |
|
35 |
| -> **Requires:** |
36 |
| -- **[PHP 8.2+](https://php.net/releases/)** |
37 |
| -- **[Laravel 11.15+](https://github.com/laravel/laravel)** |
| 29 | +- [feat: support dynamic relation closures](https://github.com/larastan/larastan/pull/2048) |
| 30 | +- [feat: add support for config array shapes](https://github.com/larastan/larastan/pull/2004) |
| 31 | +- [feat: support multiple database connections](https://github.com/larastan/larastan/pull/1879) |
| 32 | +- [feat: support wildcards in migration/schema paths](https://github.com/larastan/larastan/pull/2031) |
| 33 | +- [fix: default date casting](https://github.com/larastan/larastan/pull/1842) |
| 34 | +- [fix: make TGet covariant on Attribute stub](https://github.com/larastan/larastan/pull/2014) |
38 | 35 |
|
39 |
| -**1**: First, you may use [Composer](https://getcomposer.org) to install Larastan as a development dependency into your Laravel project: |
| 36 | +## ✨ Getting Started |
40 | 37 |
|
41 |
| -```bash |
42 |
| -composer require --dev "larastan/larastan:^3.0" |
43 |
| -``` |
44 |
| - |
45 |
| -> Using Larastan for analysing Laravel packages? You may need to install `orchestra/testbench`. |
46 |
| -
|
47 |
| -**2**: Then, create a `phpstan.neon` or `phpstan.neon.dist` file in the root of your application. It might look like this: |
48 |
| - |
49 |
| -``` |
50 |
| -includes: |
51 |
| - - vendor/larastan/larastan/extension.neon |
52 |
| - - vendor/nesbot/carbon/extension.neon |
53 |
| -
|
54 |
| -parameters: |
55 |
| -
|
56 |
| - paths: |
57 |
| - - app/ |
58 |
| -
|
59 |
| - # Level 10 is the highest level |
60 |
| - level: 5 |
61 |
| -
|
62 |
| -# ignoreErrors: |
63 |
| -# - '#PHPDoc tag @var#' |
64 |
| -# |
65 |
| -# excludePaths: |
66 |
| -# - ./*/*/FileToBeExcluded.php |
67 |
| -``` |
68 |
| - |
69 |
| -For all available options, please take a look at the PHPStan documentation: **https://phpstan.org/config-reference** |
70 |
| - |
71 |
| -**3**: Finally, you may start analyzing your code using the phpstan console command: |
| 38 | +To use this fork, you may use [Composer][composer] to install it as a development dependency into your Laravel project: |
72 | 39 |
|
73 | 40 | ```bash
|
74 |
| -./vendor/bin/phpstan analyse |
75 |
| -``` |
76 |
| - |
77 |
| -If you are getting the error `Allowed memory size exhausted`, then you can use the `--memory-limit` option fix the problem: |
78 |
| - |
79 |
| -```bash |
80 |
| -./vendor/bin/phpstan analyse --memory-limit=2G |
81 |
| -``` |
82 |
| - |
83 |
| -## Ignoring errors |
84 |
| - |
85 |
| -Ignoring a specific error can be done either with a php comment or in the configuration file: |
86 |
| - |
87 |
| -```php |
88 |
| -// @phpstan-ignore-next-line |
89 |
| -$test->badMethod(); |
90 |
| - |
91 |
| -$test->badMethod(); // @phpstan-ignore-line |
| 41 | +composer require --dev "calebdw/larastan:^3.0" |
92 | 42 | ```
|
93 | 43 |
|
94 |
| -When ignoring errors in PHPStan's configuration file, they are ignored by writing a regex based on error messages: |
| 44 | +Or if you already have the upstream package installed, you can point your `composer.json` to this fork: |
95 | 45 |
|
96 |
| -```yaml |
97 |
| -parameters: |
98 |
| - ignoreErrors: |
99 |
| - - '#Call to an undefined method .*badMethod\(\)#' |
| 46 | +```diff |
| 47 | +- "larastan/larastan": "^3.0" |
| 48 | ++ "calebdw/larastan": "^3.0" |
100 | 49 | ```
|
101 | 50 |
|
102 |
| -### Baseline file |
103 |
| -
|
104 |
| -In older codebases it might be hard to spend the time fixing all the code to pass a high PHPStan Level. |
| 51 | +If you have the [PHPStan extension installer](https://phpstan.org/user-guide/extension-library#installing-extensions) installed then nothing more is needed, otherwise you will need to manually include the extension in the `phpstan.neon(.dist)` configuration file: |
105 | 52 |
|
106 |
| -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](https://phpstan.org/user-guide/baseline)) |
107 |
| -
|
108 |
| -```bash |
109 |
| -./vendor/bin/phpstan analyse --generate-baseline |
| 53 | +```neon |
| 54 | +includes: |
| 55 | + - ./vendor/calebdw/larastan/extension.neon |
110 | 56 | ```
|
111 | 57 |
|
112 |
| -## Rules |
113 |
| - |
114 |
| -A list of configurable rules specific to Laravel can be found [here](docs/rules.md). |
115 |
| - |
116 |
| - |
117 |
| -## Features |
118 |
| - |
119 |
| -A list of Larastan features can be found [here](docs/features.md). |
120 |
| - |
121 |
| -## Custom PHPDoc types |
122 |
| - |
123 |
| -A list of PHPDoc types specific to Larastan can be found [here](docs/custom-types.md). |
124 |
| - |
125 |
| -## Custom PHPStan config parameters |
126 |
| - |
127 |
| -A list of custom config parameters that you can use in your PHPStan config file can be found [here](docs/custom-config-parameters.md). |
128 |
| - |
129 |
| -## Errors To Ignore |
130 |
| - |
131 |
| -Some parts of Laravel are currently too magical for Larastan/PHPStan to understand. |
132 |
| -We listed common [errors to ignore](docs/errors-to-ignore.md), add them as needed |
| 58 | +For more information on how to configure and use Larastan, please refer to the [official documentation][larastan]. |
133 | 59 |
|
134 | 60 | ## 👊🏻 Contributing
|
135 | 61 |
|
136 | 62 | Thank you for considering contributing to Larastan. All the contribution guidelines are mentioned [here](CONTRIBUTING.md).
|
137 | 63 |
|
138 |
| -## 📖 License |
| 64 | +## 📄 License |
| 65 | + |
| 66 | +This fork is open-sourced software licensed under the [MIT license](LICENSE.md). |
139 | 67 |
|
140 |
| -Larastan is an open-sourced software licensed under the [MIT license](LICENSE.md). |
| 68 | +<!-- links --> |
| 69 | +[composer]: https://getcomposer.org |
| 70 | +[larastan]: https://github.com/larastan/larastan |
| 71 | +[larastan-livewire]: https://github.com/calebdw/larastan-livewire |
| 72 | +[livewire]: https://github.com/livewire/livewire |
0 commit comments