Skip to content

Local TypeHinting #4430

Open
Open
@steelbrain

Description

@steelbrain

We can check typehint when giving providing or taking it from a function, but how can we typehint something locally?

What works already:

type User = shape('id' => int);
function OnlineStatus(User $user):void{
    DB::UserOnline($user); // this function expects a type User
}
OnlineStatus(shape('id' => 1));

btw, phpStorm uses this syntax for local type hinting

type User = shape('id' => int);
/**
 * @var User
*/
$user = shape("id" => int);
DB::UserOnline($user)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions