vyuldashev / nova-permission

A Laravel Nova tool for Spatie's laravel-permission library
https://novapackages.com/packages/vyuldashev/nova-permission
419 stars 217 forks source link

Adding PHP 7.4 compatibility #161

Closed dualklip closed 3 years ago

dualklip commented 3 years ago

If the project is running on PHP 7.4 appears errors related with variables not types

Type of Vyuldashev\NovaPermission\Role::$title must be string (as in class Laravel\Nova\Resource)

This PR fix the issue in PHP 7.4

vyuldashev commented 3 years ago

Released under v3.0.0

dualklip commented 3 years ago

Thank you for your approval!

argia-andreas commented 3 years ago

@dualklip Hi! Which version of Nova are you running?

We are now getting the opposite problem after this commit :-) On PHP 7.4 and PHP 8.0

Symfony\Component\ErrorHandler\Error\FatalError: Type of Vyuldashev\NovaPermission\Role::$title must not be defined (as in class Laravel\Nova\Resource) in file /vendor/vyuldashev/nova-permission/src/Role.php on line 0

For example: Checking the nova source for Resource.php:

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'id';

and Role.php after this PR:

/**     
* The single value that should be used to represent the resource when being displayed.     
*     
* @var string     
*/ 
public static string $title = 'name';

Are your version of Nova Resource.php typehinted? Or am I missing something here?

dualklip commented 3 years ago

Hi @argia-andreas

You are right! In the issue #160 we are discussing about how revert the fix, because after the Nova 3.25.0 the type hinting is not needed any more.

I'm waiting an answer from @vyuldashev to know how to proceed, in the meantime you can block the composer to the v2.11.1 tag which is working on the Nova 3.25.0

composer require vyuldashev/nova-permission:v2.11.1

argia-andreas commented 3 years ago

Ok, great! Thanks for the quick answer! :-) I'm not crazy then :-) I was looking through different versions on Nova expecting to find it typehinted in one of them. But couldn't find it. Missed the one version where it was typehinted 🙄

Didn't see #160.

Then we'll just wait for a fix to be decided upon.