orchidsoftware / platform

Orchid is a @laravel package that allows for rapid application development of back-office applications, admin/user panels, and dashboards.
https://orchid.software
MIT License
4.45k stars 655 forks source link

PHPStan issue when the return type of Field::value is self #2898

Closed ilampropoulos closed 2 months ago

ilampropoulos commented 2 months ago

Issue When the return type of the value method is self, PHPStan gives this error:

Screenshot 2024-09-24 165425

for this code snippet that inherit your value method.

public function value($value): static
    {
        if (empty($value)) {
            $value = [];
        }

        return parent::value($value);
    }

PHPStan works correctly only when you change the return type from self to static, as I suggested in my PR. So, you need to change to static if you want the method to be compatible with subclasses.