Skip to content

Commit 08c128e

Browse files
committed
Address code review
1 parent 6a4118d commit 08c128e

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Test that the mixed parameter type can have any default value
3+
--FILE--
4+
<?php
5+
6+
function foo(mixed $a = null, mixed $b = false, mixed $c = 1, mixed $d = 3.13, mixed $e = "", mixed $f = [])
7+
{
8+
}
9+
10+
?>
11+
--EXPECT--

Zend/tests/type_declarations/mixed/syntax/nullable_mixed_parameter_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ function foo(?mixed $a)
99

1010
?>
1111
--EXPECTF--
12-
Fatal error: Type mixed cannot be nullable in %s on line %d
12+
Fatal error: Type mixed cannot be marked as nullable since mixed already includes null in %s on line %d

Zend/tests/type_declarations/mixed/syntax/nullable_mixed_property_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class Foo
1010

1111
?>
1212
--EXPECTF--
13-
Fatal error: Type mixed cannot be nullable in %s on line %d
13+
Fatal error: Type mixed cannot be marked as nullable since mixed already includes null in %s on line %d

Zend/tests/type_declarations/mixed/syntax/nullable_mixed_return_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ function foo(): ?mixed
99

1010
?>
1111
--EXPECTF--
12-
Fatal error: Type mixed cannot be nullable in %s on line %d
12+
Fatal error: Type mixed cannot be marked as nullable since mixed already includes null in %s on line %d

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5671,8 +5671,8 @@ static zend_type zend_compile_typename(
56715671
ZSTR_VAL(type_str));
56725672
}
56735673

5674-
if ((type_mask == MAY_BE_ANY) && allow_null) {
5675-
zend_error_noreturn(E_COMPILE_ERROR, "Type mixed cannot be nullable");
5674+
if (type_mask == MAY_BE_ANY && allow_null && !force_allow_null) {
5675+
zend_error_noreturn(E_COMPILE_ERROR, "Type mixed cannot be marked as nullable since mixed already includes null");
56765676
}
56775677

56785678
if ((type_mask & MAY_BE_OBJECT) && (ZEND_TYPE_HAS_CLASS(type) || (type_mask & MAY_BE_STATIC))) {

ext/reflection/tests/mixed_type.phpt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@ $method = new ReflectionMethod($a, "test");
1717
var_dump($object->getProperty("a")->getType()->getName());
1818
var_dump($method->getParameters()[0]->getType()->getName());
1919
var_dump($method->getReturnType()->getName());
20+
21+
var_dump((string) $object->getProperty("a"));
22+
var_dump((string) $method->getParameters()[0]);
23+
var_dump((string) $method->getReturnType());
24+
2025
?>
2126
--EXPECT--
2227
string(5) "mixed"
2328
string(5) "mixed"
2429
string(5) "mixed"
30+
string(29) "Property [ public mixed $a ]
31+
"
32+
string(36) "Parameter #0 [ <required> mixed $a ]"
33+
string(5) "mixed"

0 commit comments

Comments
 (0)