Larastan: Allow using non-integer model IDs

Created on 17 Apr 2020  路  3Comments  路  Source: nunomaduro/larastan

  • Larastan Version: 0.5.5
  • --level used: max

Description

PR #499 allows only (!) integer type for model IDs.

But we are using UUID for some models IDs and static analysis failing.

I propose to rollback the PR.

Laravel code where the issue was found

/**
 * @property string $user
 */
class User extends Model
{
/...
}

function foo(string $foo): void
{
    echo $foo;
}

foo($user->id);

Most helpful comment

Hi,

This is fixed in the current master. You can specify a type for your id property in the annotation, and that will be used.

/**
 * @property string $id
 */
class User extends Model
{
}

All 3 comments

So you'd like to have int|string?

Hi,

This is fixed in the current master. You can specify a type for your id property in the annotation, and that will be used.

/**
 * @property string $id
 */
class User extends Model
{
}

@canvural cool, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gitetsu picture gitetsu  路  4Comments

danielcosta picture danielcosta  路  4Comments

szepeviktor picture szepeviktor  路  4Comments

grcasanova picture grcasanova  路  4Comments

JeroenVanOort picture JeroenVanOort  路  3Comments