Skip to content

Commit

Permalink
Update link to Octane dependency injection docs (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed May 18, 2021
1 parent ba865c6 commit df7e049
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Fixed

- Update link to Octane dependency injection docs ([#829](https://github.com/nunomaduro/larastan/pull/829))

## [0.7.5] - 2021-04-29

### Added
Expand Down
3 changes: 2 additions & 1 deletion docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ takesOnlyUserModelProperties('emaiil');

## OctaneCompatibilityRule

This is an optional rule that can check your application for Laravel Octane compatibility. You can read more about why in the official [Octane docs](https://github.com/laravel/octane#dependency-injection--octane).
This is an optional rule that can check your application for Laravel Octane compatibility.
You can read more about why in [the official Octane docs](https://laravel.com/docs/octane#dependency-injection-and-octane).

### Configuration

Expand Down
28 changes: 12 additions & 16 deletions src/Rules/OctaneCompatibilityRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PhpParser\NodeFinder;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleError;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\Type\ObjectType;

Expand Down Expand Up @@ -120,14 +121,7 @@ public function processNode(Node $node, Scope $scope): array
});

if (count($nodes) > 0) {
$errors = [];

foreach ($nodes as $node) {
$errors[] = RuleErrorBuilder::message('Consider using bind method instead or pass a closure.')
->identifier('rules.octane')->tip('See: https://github.com/laravel/octane#dependency-injection--octane')->line($node->getAttribute('startLine'))->build();
}

return $errors;
return array_map([$this, 'dependencyInjectionError'], $nodes);
}

return [];
Expand All @@ -145,16 +139,18 @@ private function checkForThisAppUsage(Scope $scope, Node\Expr\Closure $closure):
});

if (count($nodes) > 0) {
$errors = [];

foreach ($nodes as $node) {
$errors[] = RuleErrorBuilder::message('Consider using bind method instead or pass a closure.')
->identifier('rules.octane')->tip('See: https://github.com/laravel/octane#dependency-injection--octane')->line($node->getAttribute('startLine'))->build();
}

return $errors;
return array_map([$this, 'dependencyInjectionError'], $nodes);
}

return [];
}

private function dependencyInjectionError(Node $node): RuleError
{
return RuleErrorBuilder::message('Consider using bind method instead or pass a closure.')
->identifier('rules.octane')
->tip('See: https://laravel.com/docs/octane#dependency-injection-and-octane')
->line($node->getAttribute('startLine'))
->build();
}
}

0 comments on commit df7e049

Please sign in to comment.