Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
use JetBrains\PhpStorm\ArrayShape;
class Role {
protected string $role;
public function __construct(int $role) {
$this->role = $role;
}
public function getRole(): string {
return $this->role;
}
}
#[ArrayShape([
"id" => "int",
"name" => "string",
"role" => Role::class,
])]
function user(): array {
return [
"id" => 1,
"name" => "cursosdesarrolloweb",
"role" => new Role(1)
];
}
$user = user();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment