Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adjust newFactory method visibility#1735

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

brandonfarber
Copy link
Contributor

PHP: 8.3.4
Laravel Framework: 11.2.0
Laravel Passport: 12.0.2

At command line, attempting to create a client_credentials client from instructions in the documentation results in a PHP Fatal error.

 ~/Documents/GitHub/project/ [main*] sail artisan passport:client --client What should we name the client? [Project ClientCredentials Grant Client]: > APIPHP Fatal error:  Access level to Illuminate\Database\Eloquent\Factories\HasFactory::newFactory() must be public (as in class Laravel\Passport\Client) in /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factories/HasFactory.php on line 28   Symfony\Component\ErrorHandler\Error\FatalError   Access level to Illuminate\Database\Eloquent\Factories\HasFactory::newFactory() must be public (as in class Laravel\Passport\Client)  at vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factories/HasFactory.php:28     24▕      * Create a new factory instance for the model.     25▕      *     26▕      * @return \Illuminate\Database\Eloquent\Factories\Factory<static>     27▕      */  ➜  28▕     protected static function newFactory()     29▕     {     30▕         //     31▕     }     32▕ }   Whoops\Exception\ErrorException   Access level to Illuminate\Database\Eloquent\Factories\HasFactory::newFactory() must be public (as in class Laravel\Passport\Client)  at vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factories/HasFactory.php:28     24▕      * Create a new factory instance for the model.     25▕      *     26▕      * @return \Illuminate\Database\Eloquent\Factories\Factory<static>     27▕      */  ➜  28▕     protected static function newFactory()     29▕     {     30▕         //     31▕     }     32▕ }      +1 vendor frames   2   [internal]:0      Whoops\Run::handleShutdown()

The newFactory() method defined in the trait has a protected visibility, while the method has a public visibility in this class implementing the trait, resulting in a visibility compatibility error. Theas operator could be used to adjust the method visibility, but this seemed like the better, clearer and more straightforward approach.

This method overrides the newFactory() method in the HasFactory trait, which is protected, resulting in a fatal error in PHP 8.3
@taylorotwelltaylorotwell merged commitb33d6fc intolaravel:12.xApr 5, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@brandonfarber@taylorotwell

[8]ページ先頭

©2009-2025 Movatter.jp