Skip to content

Instantly share code, notes, and snippets.

@jimbojsb
Forked from ralphschindler/scalar-type-signatures.php
Last active August 29, 2015 14:17
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 jimbojsb/0b464180ffcde10fce74 to your computer and use it in GitHub Desktop.
Save jimbojsb/0b464180ffcde10fce74 to your computer and use it in GitHub Desktop.
<?php
// coercive types, as per PersonFactory author's specification
class ElePHPant {
public $name, $age, $cuteness, $evil;
public function __construct(~string $name, ~int $age, ~float $cuteness, ~bool $evil) {
$this->name = $name;
$this->age = $age;
$this->cuteness = $cuteness;
$this->evil = $evil;
}
}
// forced types, as per PersonFactory author's specification
class ElePHPant {
public $name, $age, $cuteness, $evil;
public function __construct(string $name, int $age, float $cuteness, bool $evil) {
$this->name = $name;
$this->age = $age;
$this->cuteness = $cuteness;
$this->evil = $evil;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment