Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update link to Octane dependency injection docs #829

Merged
merged 3 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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();
}
}