PHP7.2+ compatible strict types and type hinting

This commit is contained in:
Pen-y-Fan
2020-05-18 22:50:05 +01:00
parent 8500dd433d
commit 9cf94c2653
3 changed files with 46 additions and 15 deletions
+12 -4
View File
@@ -1,16 +1,24 @@
<?php
declare(strict_types=1);
namespace Theatrical;
class Invoice
{
public string $customer;
public array $performances;
/**
* @var string
*/
public $customer;
public function __construct($customer, $performances)
/**
* @var array
*/
public $performances;
public function __construct(string $customer, array $performances)
{
$this->customer = $customer;
$this->performances = $performances;
}
}
+17 -3
View File
@@ -1,13 +1,27 @@
<?php
declare(strict_types=1);
namespace Theatrical;
class Performance
{
public string $play_id;
public int $audience;
/**
* @var string
*/
public $play_id;
public function __construct($play_id, $audience)
/**
* @var int
*/
public $audience;
/**
* @var Play
*/
public $play;
public function __construct(string $play_id, int $audience)
{
$this->play_id = $play_id;
$this->audience = $audience;
+12 -3
View File
@@ -1,13 +1,22 @@
<?php
declare(strict_types=1);
namespace Theatrical;
class Play
{
public string $name;
public string $type;
/**
* @var string
*/
public $name;
public function __construct($name, $type)
/**
* @var string
*/
public $type;
public function __construct(string $name, string $type)
{
$this->name = $name;
$this->type = $type;