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

Fixes PHPStan errors #364

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: vendor/bin/phpstan --error-format=github
run: vendor/bin/phpstan --error-format=github --verbose
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"laravel/framework": "^7.20|^8.19|^9.0|^10.0|^11.0",
"orchestra/testbench-core": "^5.0|^6.0|^7.0|^8.0|^9.0",
"pestphp/pest": "^1.22|^2.0",
"phpstan/phpstan": "^1.10.57",
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^9.3|^10.1",
"spatie/pest-plugin-snapshots": "^1.1|^2.0",
"symfony/var-dumper": "^4.2|^5.1|^6.0|^7.0.3"
Expand Down
6 changes: 0 additions & 6 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@ parameters:
- '#^Call to method \w+\(\) on an unknown class Spatie\\WordPressRay\\Ray\.$#'
- '#^Call to method \w+\(\) on an unknown class Spatie\\RayBundle\\Ray\.$#'
- '#^Access to an undefined property Spatie\\Ray\\Settings\\Settings\:\:\$\w+\.$#'
-
message: '#^Access to an undefined property Spatie\\LaravelRay\\RayServiceProvider\:\:\$items\.$#'
path: src/RayServiceProvider.php
-
message: '#^Access to an undefined property Spatie\\LaravelRay\\RayServiceProvider\:\:\$value\.$#'
path: src/RayServiceProvider.php
4 changes: 2 additions & 2 deletions src/OriginFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function getOrigin(): Origin
$frame = $this->getFrame();

return new Origin(
optional($frame)->file,
optional($frame)->lineNumber,
optional($frame)->file, // @phpstan-ignore property.notFound
optional($frame)->lineNumber, // @phpstan-ignore property.notFound
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/RayServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ protected function registerMacros(): self
{
Collection::macro('ray', function (string $description = '') {
$description === ''
? ray($this->items)
: ray($description, $this->items);
? ray($this->items) // @phpstan-ignore property.protected
: ray($description, $this->items); // @phpstan-ignore property.protected

return $this;
});
Expand All @@ -206,8 +206,8 @@ protected function registerMacros(): self

Stringable::macro('ray', function (string $description = '') {
$description === ''
? ray($this->value)
: ray($description, $this->value);
? ray($this->value) // @phpstan-ignore property.protected
: ray($description, $this->value); // @phpstan-ignore property.protected

return $this;
});
Expand Down
1 change: 1 addition & 0 deletions src/Watchers/CacheWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function register(): void

$ray = $this->ray()->sendRequest($payload);

/** @phpstan-ignore method.notFound */
optional($this->rayProxy)->applyCalledMethods($ray);
});

Expand Down
1 change: 1 addition & 0 deletions src/Watchers/DuplicateQueryWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function register(): void

$ray = app(Ray::class)->sendRequest($payload);

/** @phpstan-ignore method.notFound */
optional($this->rayProxy)->applyCalledMethods($ray);
});
}
Expand Down
1 change: 1 addition & 0 deletions src/Watchers/EventWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function register(): void

$ray = app(Ray::class)->sendRequest($payload);

/** @phpstan-ignore method.notFound */
optional($this->rayProxy)->applyCalledMethods($ray);
});
}
Expand Down
1 change: 1 addition & 0 deletions src/Watchers/ExceptionWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function getFlareReport(Throwable $exception): ?array
if (app()->bound(Flare::class)) {
$flare = app(Flare::class);

/** @phpstan-ignore class.notFound */
$report = $flare->createReport($exception);

return (new ReportTrimmer())->trim($report->toArray());
Expand Down
2 changes: 2 additions & 0 deletions src/Watchers/HttpClientWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function register(): void

$ray = $this->handleRequest($event->request);

/** @phpstan-ignore method.notFound */
optional($this->rayProxy)->applyCalledMethods($ray);
});

Expand All @@ -40,6 +41,7 @@ public function register(): void

$ray = $this->handleResponse($event->request, $event->response);

/** @phpstan-ignore method.notFound */
optional($this->rayProxy)->applyCalledMethods($ray);
});
}
Expand Down
1 change: 1 addition & 0 deletions src/Watchers/JobWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function register(): void

$ray = app(Ray::class)->sendRequest($payload);

/** @phpstan-ignore method.notFound */
optional($this->rayProxy)->applyCalledMethods($ray);
});
}
Expand Down
1 change: 1 addition & 0 deletions src/Watchers/QueryWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function register(): void

$ray = app(Ray::class)->sendRequest($payload);

/** @phpstan-ignore method.notFound */
optional($this->rayProxy)->applyCalledMethods($ray);
});
}
Expand Down
5 changes: 3 additions & 2 deletions src/Watchers/RequestWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function register(): void

$ray = $this->handleRequest($event->request, $event->response);

/** @phpstan-ignore method.notFound */
optional($this->rayProxy)->applyCalledMethods($ray);
});
}
Expand All @@ -54,8 +55,8 @@ protected function handleRequest(Request $request, Response $response): Ray
'IP Address' => $request->ip(),
'URI' => str_replace($request->root(), '', $request->fullUrl()) ?: '/',
'Method' => $request->method(),
'Controller action' => optional($request->route())->getActionName(),
'Middleware' => array_values(optional($request->route())->gatherMiddleware() ?? []),
'Controller action' => optional($request->route())->getActionName(), // @phpstan-ignore method.notFound
'Middleware' => array_values(optional($request->route())->gatherMiddleware() ?? []), // @phpstan-ignore method.notFound
'Headers' => $headers,
'Payload' => $this->payload($request),
'Session' => $session,
Expand Down
1 change: 1 addition & 0 deletions src/Watchers/SlowQueryWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function register(): void
$ray->sendRequest($payload);
}

/** @phpstan-ignore method.notFound */
optional($this->rayProxy)->applyCalledMethods($ray);
});
}
Expand Down
1 change: 1 addition & 0 deletions src/Watchers/ViewWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function register(): void

$ray = app(Ray::class)->view($view);

/** @phpstan-ignore method.notFound */
optional($this->rayProxy)->applyCalledMethods($ray);
});
}
Expand Down