forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-13775.php
More file actions
37 lines (25 loc) · 1.15 KB
/
bug-13775.php
File metadata and controls
37 lines (25 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php declare(strict_types = 1);
$a = [null];
echo 'null, valid cast: ' . array_product($a) . "\n\n";
$a = [false];
echo 'false, valid cast: ' . array_product($a) . "\n\n";
$a = [true];
echo 'true, valid cast: ' . array_product($a) . "\n\n";
$a = [''];
echo 'empty string, invalid cast: ' . array_product($a) . "\n\n";
$a = ['42.5'];
echo 'string of a float, valid cast: ' . array_product($a) . "\n\n";
$a = ['42,5'];
echo 'string of comma-separated float, valid cast but not desirable (discards trailing chars): ' . array_product($a) . "\n\n";
$a = ['42a'];
echo 'string of int with trailing alpha char, valid cast but not desirable (discards trailing chars): ' . array_product($a) . "\n\n";
$a = ['a42'];
echo 'string of int with leading alpha char, invalid cast: ' . array_product($a) . "\n\n";
$a = [[]];
echo 'array, invalid cast: ' . array_product($a) . "\n\n";
$a = [new stdClass()];
echo 'class that does not auto-cast, invalid cast: ' . array_product($a) . "\n\n";
$a = [rand(0, 1) ? new stdClass() : gmp_init(42)];
echo 'possibly invalid cast: ' . array_product($a) . "\n\n";
$a = [gmp_init(42)];
echo 'gmp, valid cast: ' . array_product($a) . "\n\n";