Skip to content

Commit 6c6235f

Browse files
committed
New test and test fix in Zend/
1 parent 1ca83d1 commit 6c6235f

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Union of int|string shouldn't warn if string semantics are used
3+
--FILE--
4+
<?php
5+
6+
$float = 1.0;
7+
8+
function foo(int|string $a): void {
9+
var_dump($a);
10+
}
11+
12+
foo(1.0);
13+
foo(1.5);
14+
foo(fdiv(0, 0));
15+
foo(10e120);
16+
foo(10e500); // Infinity
17+
18+
19+
20+
?>
21+
--EXPECTF--
22+
int(1)
23+
24+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
25+
int(1)
26+
string(3) "NAN"
27+
string(8) "1.0E+121"
28+
string(3) "INF"

Zend/tests/operator_unsupported_types.phpt

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ $legalValues = [
3131
'true',
3232
'false',
3333
'2',
34-
'3.5',
34+
'3.5', // Semi-legal for certain ops
3535
'"123"',
3636
'"123foo"', // Semi-legal
3737
];
3838

3939
set_error_handler(function($errno, $errstr) {
40-
assert($errno == E_WARNING);
40+
assert($errno == E_WARNING || $errno == E_DEPRECATED);
4141
echo "Warning: $errstr\n";
4242
});
4343

@@ -453,6 +453,7 @@ Unsupported operand types: bool % array
453453
Unsupported operand types: array % int
454454
Unsupported operand types: int % array
455455
Unsupported operand types: array % float
456+
Warning: Implicit conversion to int from non-compatible float
456457
Unsupported operand types: float % array
457458
Unsupported operand types: array % string
458459
Unsupported operand types: string % array
@@ -468,6 +469,7 @@ Unsupported operand types: bool % stdClass
468469
Unsupported operand types: stdClass % int
469470
Unsupported operand types: int % stdClass
470471
Unsupported operand types: stdClass % float
472+
Warning: Implicit conversion to int from non-compatible float
471473
Unsupported operand types: float % stdClass
472474
Unsupported operand types: stdClass % string
473475
Unsupported operand types: string % stdClass
@@ -483,6 +485,7 @@ Unsupported operand types: bool % resource
483485
Unsupported operand types: resource % int
484486
Unsupported operand types: int % resource
485487
Unsupported operand types: resource % float
488+
Warning: Implicit conversion to int from non-compatible float
486489
Unsupported operand types: float % resource
487490
Unsupported operand types: resource % string
488491
Unsupported operand types: string % resource
@@ -498,6 +501,7 @@ Unsupported operand types: bool % string
498501
Unsupported operand types: string % int
499502
Unsupported operand types: int % string
500503
Unsupported operand types: string % float
504+
Warning: Implicit conversion to int from non-compatible float
501505
Unsupported operand types: float % string
502506
Unsupported operand types: string % string
503507
Unsupported operand types: string % string
@@ -605,6 +609,7 @@ Unsupported operand types: bool << array
605609
Unsupported operand types: array << int
606610
Unsupported operand types: int << array
607611
Unsupported operand types: array << float
612+
Warning: Implicit conversion to int from non-compatible float
608613
Unsupported operand types: float << array
609614
Unsupported operand types: array << string
610615
Unsupported operand types: string << array
@@ -620,6 +625,7 @@ Unsupported operand types: bool << stdClass
620625
Unsupported operand types: stdClass << int
621626
Unsupported operand types: int << stdClass
622627
Unsupported operand types: stdClass << float
628+
Warning: Implicit conversion to int from non-compatible float
623629
Unsupported operand types: float << stdClass
624630
Unsupported operand types: stdClass << string
625631
Unsupported operand types: string << stdClass
@@ -635,6 +641,7 @@ Unsupported operand types: bool << resource
635641
Unsupported operand types: resource << int
636642
Unsupported operand types: int << resource
637643
Unsupported operand types: resource << float
644+
Warning: Implicit conversion to int from non-compatible float
638645
Unsupported operand types: float << resource
639646
Unsupported operand types: resource << string
640647
Unsupported operand types: string << resource
@@ -650,6 +657,7 @@ Unsupported operand types: bool << string
650657
Unsupported operand types: string << int
651658
Unsupported operand types: int << string
652659
Unsupported operand types: string << float
660+
Warning: Implicit conversion to int from non-compatible float
653661
Unsupported operand types: float << string
654662
Unsupported operand types: string << string
655663
Unsupported operand types: string << string
@@ -681,6 +689,7 @@ Unsupported operand types: bool >> array
681689
Unsupported operand types: array >> int
682690
Unsupported operand types: int >> array
683691
Unsupported operand types: array >> float
692+
Warning: Implicit conversion to int from non-compatible float
684693
Unsupported operand types: float >> array
685694
Unsupported operand types: array >> string
686695
Unsupported operand types: string >> array
@@ -696,6 +705,7 @@ Unsupported operand types: bool >> stdClass
696705
Unsupported operand types: stdClass >> int
697706
Unsupported operand types: int >> stdClass
698707
Unsupported operand types: stdClass >> float
708+
Warning: Implicit conversion to int from non-compatible float
699709
Unsupported operand types: float >> stdClass
700710
Unsupported operand types: stdClass >> string
701711
Unsupported operand types: string >> stdClass
@@ -711,6 +721,7 @@ Unsupported operand types: bool >> resource
711721
Unsupported operand types: resource >> int
712722
Unsupported operand types: int >> resource
713723
Unsupported operand types: resource >> float
724+
Warning: Implicit conversion to int from non-compatible float
714725
Unsupported operand types: float >> resource
715726
Unsupported operand types: resource >> string
716727
Unsupported operand types: string >> resource
@@ -726,6 +737,7 @@ Unsupported operand types: bool >> string
726737
Unsupported operand types: string >> int
727738
Unsupported operand types: int >> string
728739
Unsupported operand types: string >> float
740+
Warning: Implicit conversion to int from non-compatible float
729741
Unsupported operand types: float >> string
730742
Unsupported operand types: string >> string
731743
Unsupported operand types: string >> string
@@ -757,6 +769,7 @@ Unsupported operand types: bool & array
757769
Unsupported operand types: array & int
758770
Unsupported operand types: int & array
759771
Unsupported operand types: array & float
772+
Warning: Implicit conversion to int from non-compatible float
760773
Unsupported operand types: float & array
761774
Unsupported operand types: array & string
762775
Unsupported operand types: string & array
@@ -800,6 +813,7 @@ Unsupported operand types: bool & string
800813
Unsupported operand types: string & int
801814
Unsupported operand types: int & string
802815
Unsupported operand types: string & float
816+
Warning: Implicit conversion to int from non-compatible float
803817
Unsupported operand types: float & string
804818
No error for "foo" & "123"
805819
No error for "123" & "foo"
@@ -830,6 +844,7 @@ Unsupported operand types: bool | array
830844
Unsupported operand types: array | int
831845
Unsupported operand types: int | array
832846
Unsupported operand types: array | float
847+
Warning: Implicit conversion to int from non-compatible float
833848
Unsupported operand types: float | array
834849
Unsupported operand types: array | string
835850
Unsupported operand types: string | array
@@ -873,6 +888,7 @@ Unsupported operand types: bool | string
873888
Unsupported operand types: string | int
874889
Unsupported operand types: int | string
875890
Unsupported operand types: string | float
891+
Warning: Implicit conversion to int from non-compatible float
876892
Unsupported operand types: float | string
877893
No error for "foo" | "123"
878894
No error for "123" | "foo"
@@ -903,6 +919,7 @@ Unsupported operand types: bool ^ array
903919
Unsupported operand types: array ^ int
904920
Unsupported operand types: int ^ array
905921
Unsupported operand types: array ^ float
922+
Warning: Implicit conversion to int from non-compatible float
906923
Unsupported operand types: float ^ array
907924
Unsupported operand types: array ^ string
908925
Unsupported operand types: string ^ array
@@ -946,6 +963,7 @@ Unsupported operand types: bool ^ string
946963
Unsupported operand types: string ^ int
947964
Unsupported operand types: int ^ string
948965
Unsupported operand types: string ^ float
966+
Warning: Implicit conversion to int from non-compatible float
949967
Unsupported operand types: float ^ string
950968
No error for "foo" ^ "123"
951969
No error for "123" ^ "foo"
@@ -1449,6 +1467,7 @@ Unsupported operand types: bool % array
14491467
Unsupported operand types: array % int
14501468
Unsupported operand types: int % array
14511469
Unsupported operand types: array % float
1470+
Warning: Implicit conversion to int from non-compatible float
14521471
Unsupported operand types: float % array
14531472
Unsupported operand types: array % string
14541473
Unsupported operand types: string % array
@@ -1464,6 +1483,7 @@ Unsupported operand types: bool % stdClass
14641483
Unsupported operand types: stdClass % int
14651484
Unsupported operand types: int % stdClass
14661485
Unsupported operand types: stdClass % float
1486+
Warning: Implicit conversion to int from non-compatible float
14671487
Unsupported operand types: float % stdClass
14681488
Unsupported operand types: stdClass % string
14691489
Unsupported operand types: string % stdClass
@@ -1479,6 +1499,7 @@ Unsupported operand types: bool % resource
14791499
Unsupported operand types: resource % int
14801500
Unsupported operand types: int % resource
14811501
Unsupported operand types: resource % float
1502+
Warning: Implicit conversion to int from non-compatible float
14821503
Unsupported operand types: float % resource
14831504
Unsupported operand types: resource % string
14841505
Unsupported operand types: string % resource
@@ -1494,6 +1515,7 @@ Unsupported operand types: bool % string
14941515
Unsupported operand types: string % int
14951516
Unsupported operand types: int % string
14961517
Unsupported operand types: string % float
1518+
Warning: Implicit conversion to int from non-compatible float
14971519
Unsupported operand types: float % string
14981520
Unsupported operand types: string % string
14991521
Unsupported operand types: string % string
@@ -1601,6 +1623,7 @@ Unsupported operand types: bool << array
16011623
Unsupported operand types: array << int
16021624
Unsupported operand types: int << array
16031625
Unsupported operand types: array << float
1626+
Warning: Implicit conversion to int from non-compatible float
16041627
Unsupported operand types: float << array
16051628
Unsupported operand types: array << string
16061629
Unsupported operand types: string << array
@@ -1616,6 +1639,7 @@ Unsupported operand types: bool << stdClass
16161639
Unsupported operand types: stdClass << int
16171640
Unsupported operand types: int << stdClass
16181641
Unsupported operand types: stdClass << float
1642+
Warning: Implicit conversion to int from non-compatible float
16191643
Unsupported operand types: float << stdClass
16201644
Unsupported operand types: stdClass << string
16211645
Unsupported operand types: string << stdClass
@@ -1631,6 +1655,7 @@ Unsupported operand types: bool << resource
16311655
Unsupported operand types: resource << int
16321656
Unsupported operand types: int << resource
16331657
Unsupported operand types: resource << float
1658+
Warning: Implicit conversion to int from non-compatible float
16341659
Unsupported operand types: float << resource
16351660
Unsupported operand types: resource << string
16361661
Unsupported operand types: string << resource
@@ -1646,6 +1671,7 @@ Unsupported operand types: bool << string
16461671
Unsupported operand types: string << int
16471672
Unsupported operand types: int << string
16481673
Unsupported operand types: string << float
1674+
Warning: Implicit conversion to int from non-compatible float
16491675
Unsupported operand types: float << string
16501676
Unsupported operand types: string << string
16511677
Unsupported operand types: string << string
@@ -1677,6 +1703,7 @@ Unsupported operand types: bool >> array
16771703
Unsupported operand types: array >> int
16781704
Unsupported operand types: int >> array
16791705
Unsupported operand types: array >> float
1706+
Warning: Implicit conversion to int from non-compatible float
16801707
Unsupported operand types: float >> array
16811708
Unsupported operand types: array >> string
16821709
Unsupported operand types: string >> array
@@ -1692,6 +1719,7 @@ Unsupported operand types: bool >> stdClass
16921719
Unsupported operand types: stdClass >> int
16931720
Unsupported operand types: int >> stdClass
16941721
Unsupported operand types: stdClass >> float
1722+
Warning: Implicit conversion to int from non-compatible float
16951723
Unsupported operand types: float >> stdClass
16961724
Unsupported operand types: stdClass >> string
16971725
Unsupported operand types: string >> stdClass
@@ -1707,6 +1735,7 @@ Unsupported operand types: bool >> resource
17071735
Unsupported operand types: resource >> int
17081736
Unsupported operand types: int >> resource
17091737
Unsupported operand types: resource >> float
1738+
Warning: Implicit conversion to int from non-compatible float
17101739
Unsupported operand types: float >> resource
17111740
Unsupported operand types: resource >> string
17121741
Unsupported operand types: string >> resource
@@ -1722,6 +1751,7 @@ Unsupported operand types: bool >> string
17221751
Unsupported operand types: string >> int
17231752
Unsupported operand types: int >> string
17241753
Unsupported operand types: string >> float
1754+
Warning: Implicit conversion to int from non-compatible float
17251755
Unsupported operand types: float >> string
17261756
Unsupported operand types: string >> string
17271757
Unsupported operand types: string >> string
@@ -1753,6 +1783,7 @@ Unsupported operand types: bool & array
17531783
Unsupported operand types: array & int
17541784
Unsupported operand types: int & array
17551785
Unsupported operand types: array & float
1786+
Warning: Implicit conversion to int from non-compatible float
17561787
Unsupported operand types: float & array
17571788
Unsupported operand types: array & string
17581789
Unsupported operand types: string & array
@@ -1768,6 +1799,7 @@ Unsupported operand types: bool & stdClass
17681799
Unsupported operand types: stdClass & int
17691800
Unsupported operand types: int & stdClass
17701801
Unsupported operand types: stdClass & float
1802+
Warning: Implicit conversion to int from non-compatible float
17711803
Unsupported operand types: float & stdClass
17721804
Unsupported operand types: stdClass & string
17731805
Unsupported operand types: string & stdClass
@@ -1783,6 +1815,7 @@ Unsupported operand types: bool & resource
17831815
Unsupported operand types: resource & int
17841816
Unsupported operand types: int & resource
17851817
Unsupported operand types: resource & float
1818+
Warning: Implicit conversion to int from non-compatible float
17861819
Unsupported operand types: float & resource
17871820
Unsupported operand types: resource & string
17881821
Unsupported operand types: string & resource
@@ -1798,6 +1831,7 @@ Unsupported operand types: bool & string
17981831
Unsupported operand types: string & int
17991832
Unsupported operand types: int & string
18001833
Unsupported operand types: string & float
1834+
Warning: Implicit conversion to int from non-compatible float
18011835
Unsupported operand types: float & string
18021836
No error for "foo" &= "123"
18031837
No error for "123" &= "foo"
@@ -1828,6 +1862,7 @@ Unsupported operand types: bool | array
18281862
Unsupported operand types: array | int
18291863
Unsupported operand types: int | array
18301864
Unsupported operand types: array | float
1865+
Warning: Implicit conversion to int from non-compatible float
18311866
Unsupported operand types: float | array
18321867
Unsupported operand types: array | string
18331868
Unsupported operand types: string | array
@@ -1843,6 +1878,7 @@ Unsupported operand types: bool | stdClass
18431878
Unsupported operand types: stdClass | int
18441879
Unsupported operand types: int | stdClass
18451880
Unsupported operand types: stdClass | float
1881+
Warning: Implicit conversion to int from non-compatible float
18461882
Unsupported operand types: float | stdClass
18471883
Unsupported operand types: stdClass | string
18481884
Unsupported operand types: string | stdClass
@@ -1858,6 +1894,7 @@ Unsupported operand types: bool | resource
18581894
Unsupported operand types: resource | int
18591895
Unsupported operand types: int | resource
18601896
Unsupported operand types: resource | float
1897+
Warning: Implicit conversion to int from non-compatible float
18611898
Unsupported operand types: float | resource
18621899
Unsupported operand types: resource | string
18631900
Unsupported operand types: string | resource
@@ -1873,6 +1910,7 @@ Unsupported operand types: bool | string
18731910
Unsupported operand types: string | int
18741911
Unsupported operand types: int | string
18751912
Unsupported operand types: string | float
1913+
Warning: Implicit conversion to int from non-compatible float
18761914
Unsupported operand types: float | string
18771915
No error for "foo" |= "123"
18781916
No error for "123" |= "foo"
@@ -1903,6 +1941,7 @@ Unsupported operand types: bool ^ array
19031941
Unsupported operand types: array ^ int
19041942
Unsupported operand types: int ^ array
19051943
Unsupported operand types: array ^ float
1944+
Warning: Implicit conversion to int from non-compatible float
19061945
Unsupported operand types: float ^ array
19071946
Unsupported operand types: array ^ string
19081947
Unsupported operand types: string ^ array
@@ -1918,6 +1957,7 @@ Unsupported operand types: bool ^ stdClass
19181957
Unsupported operand types: stdClass ^ int
19191958
Unsupported operand types: int ^ stdClass
19201959
Unsupported operand types: stdClass ^ float
1960+
Warning: Implicit conversion to int from non-compatible float
19211961
Unsupported operand types: float ^ stdClass
19221962
Unsupported operand types: stdClass ^ string
19231963
Unsupported operand types: string ^ stdClass
@@ -1933,6 +1973,7 @@ Unsupported operand types: bool ^ resource
19331973
Unsupported operand types: resource ^ int
19341974
Unsupported operand types: int ^ resource
19351975
Unsupported operand types: resource ^ float
1976+
Warning: Implicit conversion to int from non-compatible float
19361977
Unsupported operand types: float ^ resource
19371978
Unsupported operand types: resource ^ string
19381979
Unsupported operand types: string ^ resource
@@ -1948,6 +1989,7 @@ Unsupported operand types: bool ^ string
19481989
Unsupported operand types: string ^ int
19491990
Unsupported operand types: int ^ string
19501991
Unsupported operand types: string ^ float
1992+
Warning: Implicit conversion to int from non-compatible float
19511993
Unsupported operand types: float ^ string
19521994
No error for "foo" ^= "123"
19531995
No error for "123" ^= "foo"

Zend/tests/runtime_compile_time_binary_operands.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Test binary operands exposing the same behavior at compile as at run time
33
--INI--
44
memory_limit=256M
5+
error_reporting=E_ALL & ~E_DEPRECATED
56
--FILE--
67
<?php
78

0 commit comments

Comments
 (0)