Skip to content

[1.x] Static analysis (PHPStan) fails on fresh install due to undefined constant in LockoutResponse #682

Description

@hamdyelbatal122

Description

When checking out the 1.x branch of laravel/fortify and running the official lint command (composer lint), the static analysis fails with exit code 1.

This is because Laravel\Fortify\Http\Responses\LockoutResponse references Illuminate\Http\Response::HTTP_TOO_MANY_REQUESTS, which is undefined in Illuminate\Http\Response's class definition without Larastan's helper mappings.

Steps To Reproduce

  1. Clone the repository and checkout the 1.x branch.
  2. Run composer install.
  3. Run composer lint (which triggers phpstan analyse).

Actual Behavior

The analysis fails with the following output:

 ------ ---------------------------------------------------
  Line   src/Http/Responses/LockoutResponse.php
 ------ ---------------------------------------------------
  49     Access to undefined constant
         Illuminate\Http\Response::HTTP_TOO_MANY_REQUESTS.
 ------ ---------------------------------------------------


 [ERROR] Found 1 error
Script @php vendor/bin/phpstan analyse handling the lint event returned with error code 1

Proposed Solution

We can replace the undefined constant Response::HTTP_TOO_MANY_REQUESTS with the direct HTTP status code 429 (which represents "Too Many Requests"). This resolves the PHPStan class constant resolution error and allows composer lint to pass successfully:

-            ])->status(Response::HTTP_TOO_MANY_REQUESTS);
+            ])->status(429);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions