parent
46ff43ba62
commit
38beb7ea29
8 changed files with 352 additions and 26 deletions
@ -0,0 +1,16 @@ |
||||
<?php |
||||
|
||||
class PropertyDefaultArrayForInt |
||||
{ |
||||
private int $a = []; |
||||
|
||||
public function __construct() |
||||
{ |
||||
var_dump($this->a); |
||||
} |
||||
} |
||||
|
||||
function property_default_array_for_int(): void |
||||
{ |
||||
$test = new PropertyDefaultArrayForInt(); |
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
<?php |
||||
|
||||
class PropertyDefaultArrayForObjectDep |
||||
{ |
||||
} |
||||
|
||||
class PropertyDefaultArrayForObject |
||||
{ |
||||
public PropertyDefaultArrayForObjectDep $dep = []; |
||||
} |
||||
|
||||
function property_default_array_for_object(): void |
||||
{ |
||||
$test = new PropertyDefaultArrayForObject(); |
||||
} |
||||
@ -0,0 +1,11 @@ |
||||
<?php |
||||
|
||||
class PropertyDefaultNullForInt |
||||
{ |
||||
public int $a = null; |
||||
} |
||||
|
||||
function property_default_null_for_int(): void |
||||
{ |
||||
$test = new PropertyDefaultNullForInt(); |
||||
} |
||||
@ -0,0 +1,11 @@ |
||||
<?php |
||||
|
||||
class PropertyDefaultStringForInt |
||||
{ |
||||
public int $a = 'hello'; |
||||
} |
||||
|
||||
function property_default_string_for_int(): void |
||||
{ |
||||
$test = new PropertyDefaultStringForInt(); |
||||
} |
||||
@ -0,0 +1,23 @@ |
||||
<?php |
||||
|
||||
class PropertyDefaultValid |
||||
{ |
||||
public int $i = 123; |
||||
public float $f = 1.5; |
||||
public float $fromInt = 3; |
||||
public string $s = 'hello'; |
||||
public bool $b = true; |
||||
public array $arr = []; |
||||
public ?int $ni = null; |
||||
public int|array $ia = []; |
||||
public mixed $m = []; |
||||
public $untyped = []; |
||||
public const NUM = 7; |
||||
public int $fromConst = self::NUM; |
||||
} |
||||
|
||||
function property_default_valid(): void |
||||
{ |
||||
$test = new PropertyDefaultValid(); |
||||
var_dump($test->i); |
||||
} |
||||
Loading…
Reference in new issue