Skip to content

Instantly share code, notes, and snippets.

@cursosdesarrolloweb
Created July 17, 2021 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cursosdesarrolloweb/4f7a982a1c26bf509cfa06b18ba4429d to your computer and use it in GitHub Desktop.
Save cursosdesarrolloweb/4f7a982a1c26bf509cfa06b18ba4429d to your computer and use it in GitHub Desktop.
<?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