-
Notifications
You must be signed in to change notification settings - Fork 0
Home
USAMI Kenta edited this page Feb 22, 2015
·
3 revisions
<?php
namespace MyApp;
final class Book
{
/** @var string */
public $title;
/** @var \MyApp\Author[] */
public $authors;
/** @var \MyApp\ISBN */
public $isbn;
/** @var string */
public $lang; // expects en|fr|zh|ru|es|ar
}
You can write this code instead of as follows.
<?php
namespace MyApp;
/**
* @property string $title
* @property \MyApp\Author[] $authors
* @property \MyApp\ISBN $isbn
* @property string $lang
*/
final class Book
{
use \Teto\Object\TypedProperty;
protected static $property_types = [
'title' => 'string',
'authors' => 'MyApp\Author[]',
'isbn' => '?MyApp\ISBN',
'lang' => 'enum',
];
protected static $property_types = [
'lang' => ['en', 'fr', 'zh', 'ru', 'es', 'ar'],
];
}