<?php
class AbilityScore
{
public $value;
public function __construct(int $value)
{
if ($value < 1)
throw new AbilityScoreTooLowException('Ability Score should be at least 1');
$this->value = $value;
}
public function __set($field, $value)
{
throw new Exception('Not here mate!');
}
}
$test = new AbilityScore(10);
$test->value = 11;
var_dump($test);
Catchable fatal error: Argument 1 passed to AbilityScore::__construct() must be an instance of int, integer given, called in /in/tbphb on line 19 and defined in /in/tbphb on line 6
Process exited with code 255.