Skip to content

Commit

Permalink
Merge pull request #564 from spawnia/reportUnmatchedIgnoredErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
canvural authored May 8, 2020
2 parents 17b27ab + 1f24b08 commit 2baa762
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added
- Document common errors for users to ignore ([#564](https://github.com/nunomaduro/larastan/pull/564))

### Changed
- Do not overwrite PHPStan's default for `reportUnmatchedIgnoredErrors` ([#564](https://github.com/nunomaduro/larastan/pull/564))

### Removed
- Stop ignoring errors ([#564](https://github.com/nunomaduro/larastan/pull/564))

## [0.5.8] - 2020-05-06

### Added
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Larastan was created by [Nuno Maduro](https://github.com/nunomaduro), got artwor
- Supports most of [Laravel](https://laravel.com)'s **beautiful magic**
- Discovers bugs in your code without running it

## ✨ Getting Started in 3 Steps
## ✨ Getting Started In 3 Steps

> **Requires:**
- **[PHP 7.2+](https://php.net/releases/)**
Expand Down Expand Up @@ -72,14 +72,21 @@ If you are getting the error `Allowed memory size exhausted`, then you can use t
```

## Rules

A list of configurable rules specific to Laravel can be found [here](docs/rules.md).

## Errors To Ignore

Some parts of Laravel are currently too magical for Larastan/PHPStan to understand.
We listed common [errors to ignore](docs/errors-to-ignore.md), add them as needed.

## 👊🏻 Contributing

Thank you for considering contributing to Larastan. All the contribution guidelines are mentioned [here](CONTRIBUTING.md).

You can have a look at the [CHANGELOG](CHANGELOG.md) 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](https://twitter.com/enunomaduro).

## ❤️ Support the development
## ❤️ Support The Development

**Do you like this project? Support it by donating**

Expand Down
40 changes: 40 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Upgrade Guide

## Upgrading to 0.6

Larastan no longer ignores errors on your behalf. Here is how you can fix them yourself:

### Result of function abort \(void\) is used

Stop `return`-ing abort.

```diff
-return abort(401);
+abort(401);
```

### Call to an undefined method Illuminate\\Support\\HigherOrder

Larastan still does not understand this particular magic, you can
[ignore it yourself](docs/errors-to-ignore.md#higher-order-messages) for now.

### Method App\\Exceptions\\Handler::render\(\) should return Illuminate\\Http\\Response but returns Symfony\\Component\\HttpFoundation\\Response

Fix the docblock.

```diff
- * @return Illuminate\Http\Response|Symfony\Component\HttpFoundation\Response
+ * @return Symfony\Component\HttpFoundation\Response
*/
public function render($request, Exception $exception)
```

### Property App\\Http\\Middleware\\TrustProxies::\$headers \(string\) does not accept default value of type int

Fix the docblock.

```diff
- * @var string
+ * @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
```

## Upgrading to 0.5.8

### Custom collections
Expand Down
23 changes: 23 additions & 0 deletions docs/errors-to-ignore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Errors To Ignore

Some parts of Laravel are currently too magical for Larastan/PHPStan to understand.

If you hit those errors in your project, you can add them to your `phpstan.neon` as needed.
[Learn more about ignoring errors in PHPStan.](https://phpstan.org/user-guide/ignoring-errors)

### Higher Order Messages

This comes up when using [higher order messages](https://laravel.com/docs/collections#higher-order-messages).

```neon
- '#Call to an undefined method Illuminate\\Support\\HigherOrder#'
```

### Factories

This comes up when you add `database/factories` to your analysed paths.

```neon
- path: database/factories/*
message: '#Undefined variable: \$factory#'
```
6 changes: 0 additions & 6 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ parameters:
- abort
excludes_analyse:
- *.blade.php
ignoreErrors:
- '#Result of function abort \(void\) is used#'
- '#Call to an undefined method Illuminate\\Support\\HigherOrder#'
- '#Method App\\Exceptions\\Handler::render\(\) should return Illuminate\\Http\\Response but returns Symfony\\Component\\HttpFoundation\\Response#'
- '#Property App\\Http\\Middleware\\TrustProxies::\$headers \(string\) does not accept default value of type int#'
bootstrap: %rootDir%/../../nunomaduro/larastan/bootstrap.php
reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false
noUnnecessaryCollectionCall: true
noUnnecessaryCollectionCallOnly: []
Expand Down

0 comments on commit 2baa762

Please sign in to comment.