Skip to content

Commit 5a9c293

Browse files
committed
Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src: (79 commits) disabled functions must not have return type Fix conditional compilation These macros should not expect any argument Avoid cold code duplication Restore the execute bit for run-tests.php Replace ZVAL_COPY() and ZVAL_COPY_VALUE() for IS_OBJECT by cheaper macros Respect optimization_level when running JIT inference Fix type inference of SEND_UNPACK with empty array SCCP: Fix handling of ASSIGN_OBJ_REF Avoid usage of internal get/set object handlers. They are going to be removed in PHP-8. Scalar FFI values now should be accessed through special "cdata" property. SCCP: Don't perform partial object propagation for typed props JIT: Fix SWITCH_LONG/STRING codegen with exact type Revert accidental changes hebrev/hebrevc: Don't return false for empty string Update MAY_BE_NULL info for more ext/standard functions Avoid double copying Update MAY_BE_NULL for parts of ext/standard Update MAY_BE_NULL func_info for Zend functions Fixed register allocation Remove FUNC_MAY_WARN ...
2 parents 48d4573 + 9f94566 commit 5a9c293

File tree

177 files changed

+9207
-5625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+9207
-5625
lines changed

Zend/tests/bug30922.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ var_dump($a instanceOf A);
1010
echo "ok\n";
1111
?>
1212
--EXPECTF--
13-
Fatal error: Interface RecurisiveFooFar cannot implement itself in %sbug30922.php on line %d
13+
Fatal error: Interface 'RecurisiveFooFar' not found in %sbug30922.php on line %d

Zend/tests/bug62441.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ namespace ns {
1616
}
1717
?>
1818
--EXPECTF--
19-
Fatal error: Declaration of ns\Foo::method(ns\stdClass $o) must be compatible with Iface::method(stdClass $o) in %s on line %d
19+
Fatal error: Could not check compatibility between ns\Foo::method(ns\stdClass $o) and Iface::method(stdClass $o), because class ns\stdClass is not available in %s on line %d

Zend/tests/bug76451.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
class Foo {}
4+
class_alias('Foo', 'Bar');

Zend/tests/bug76451.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #76451: Aliases during inheritance type checks affected by opcache
3+
--FILE--
4+
<?php
5+
require __DIR__ . "/bug76451.inc";
6+
7+
class A {
8+
public function test(Foo $foo) {}
9+
}
10+
class B extends A {
11+
public function test(Bar $foo) {}
12+
}
13+
?>
14+
===DONE===
15+
--EXPECT--
16+
===DONE===

Zend/tests/bug76451_2.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
class A {
3+
public function test(Foo $foo) {}
4+
}
5+
class B extends A {
6+
public function test(Bar $foo) {}
7+
}
8+
?>

Zend/tests/bug76451_2.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #76451: Aliases during inheritance type checks affected by opcache (variation)
3+
--FILE--
4+
<?php
5+
class Foo {}
6+
class_alias('Foo', 'Bar');
7+
8+
require __DIR__ . '/bug76451_2.inc';
9+
?>
10+
===DONE===
11+
--EXPECT--
12+
===DONE===

Zend/tests/class_name_as_scalar_error_002.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace Foo\Bar {
1111
}
1212
?>
1313
--EXPECTF--
14+
Deprecated: Cannot use "parent" when current class scope has no parent in %s on line %d
15+
1416
Fatal error: Uncaught Error: Cannot use "parent" when current class scope has no parent in %s:%d
1517
Stack trace:
1618
#0 {main}

Zend/tests/return_types/008.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class qux implements foo {
1414
}
1515

1616
$qux = new qux();
17-
var_dump($qux->bar());
18-
--EXPECTF--
19-
Fatal error: Declaration of qux::bar(): qux must be compatible with foo::bar(): foo in %s008.php on line 8
17+
echo get_class($qux->bar());
18+
19+
?>
20+
--EXPECT--
21+
qux

Zend/tests/return_types/generators003.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class SomeCollection implements Collection {
1515
}
1616

1717
$some = new SomeCollection();
18-
var_dump($some->getIterator());
19-
--EXPECTF--
20-
Fatal error: Declaration of SomeCollection::getIterator(): Generator must be compatible with Collection::getIterator(): Iterator in %sgenerators003.php on line 7
18+
echo get_class($some->getIterator());
19+
20+
?>
21+
--EXPECT--
22+
Generator

Zend/tests/return_types/inheritance005.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@ class Bar extends Foo {
1313
return new Bar;
1414
}
1515
}
16-
--EXPECTF--
17-
Fatal error: Declaration of Bar::test(): Bar must be compatible with Foo::test(): Foo in %sinheritance005.php on line 9
16+
17+
echo get_class(Bar::test());
18+
19+
?>
20+
--EXPECT--
21+
Bar

Zend/tests/return_types/inheritance006.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,9 @@ class Bar extends Foo {
1717
return new B;
1818
}
1919
}
20-
--EXPECTF--
21-
Fatal error: Declaration of Bar::test(): B must be compatible with Foo::test(): A in %sinheritance006.php on line 11
20+
21+
echo get_class(Bar::test());
22+
23+
?>
24+
--EXPECT--
25+
B

Zend/tests/return_types/inheritance007.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ class Bar extends Foo {
1515
return new ArrayObject([1, 2]);
1616
}
1717
}
18-
--EXPECTF--
19-
Fatal error: Declaration of Bar::test(): ArrayObject must be compatible with Foo::test(): Traversable in %sinheritance007.php on line 9
18+
19+
echo get_class(Bar::test());
20+
21+
?>
22+
--EXPECT--
23+
ArrayObject
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Returns are covariant, but we don't allow the code due to class ordering
3+
--FILE--
4+
<?php
5+
6+
class A {
7+
public function method() : B {}
8+
}
9+
class B extends A {
10+
public function method() : C {}
11+
}
12+
class C extends B {
13+
}
14+
15+
new C;
16+
17+
?>
18+
--EXPECTF--
19+
Fatal error: Could not check compatibility between B::method(): C and A::method(): B, because class C is not available in %s on line %d
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Returns are covariant, but we don't allow the code due to class ordering (autoload variation)
3+
--FILE--
4+
<?php
5+
6+
spl_autoload_register(function($class) {
7+
if ($class === 'A') {
8+
class A {
9+
public function method() : B {}
10+
}
11+
} else if ($class == 'B') {
12+
class B extends A {
13+
public function method() : C {}
14+
}
15+
} else {
16+
class C extends B {
17+
}
18+
}
19+
});
20+
21+
$c = new C;
22+
23+
?>
24+
--EXPECTF--
25+
Fatal error: Could not check compatibility between B::method(): C and A::method(): B, because class C is not available in %s on line %d
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Forward compatibility with types that look like classes but aren't
3+
--FILE--
4+
<?php
5+
6+
spl_autoload_register(function($class) {
7+
var_dump($class);
8+
if ($class === 'X') {
9+
class X {}
10+
} else {
11+
class Y {}
12+
}
13+
});
14+
15+
class A {
16+
public function method(X $param) : object {}
17+
}
18+
19+
class B extends A {
20+
public function method(object $param) : Y {}
21+
}
22+
23+
?>
24+
--EXPECT--
25+
string(1) "X"
26+
string(1) "Y"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Testing object's variance in inheritance
3+
--FILE--
4+
<?php
5+
6+
interface I1 {
7+
function method1(I1 $o): object;
8+
}
9+
interface I2 extends I1 {
10+
function method1(object $o): I1;
11+
}
12+
final class C1 implements I2 {
13+
function method1($o = null): self {
14+
return $this;
15+
}
16+
}
17+
18+
$o = new C1();
19+
echo get_class($o->method1());
20+
?>
21+
--EXPECT--
22+
C1
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Use of parent inside a class that has / has no parent (failure case 1)
3+
--FILE--
4+
<?php
5+
6+
// Illegal: A::parent is ill-defined
7+
class A {
8+
public function method(parent $x) {}
9+
}
10+
class B extends A {
11+
public function method(parent $x) {}
12+
}
13+
14+
?>
15+
--EXPECTF--
16+
Deprecated: Cannot use "parent" when current class scope has no parent in %s on line %d
17+
18+
Fatal error: Could not check compatibility between B::method(A $x) and A::method(parent $x), because class parent is not available in %s on line %d
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Use of parent inside a class that has / has no parent (failure case 2)
3+
--FILE--
4+
<?php
5+
6+
// Illegal: B4::parent == A4 is subclass of A4::parent == P4 in contravariant position
7+
class P4 {}
8+
class A4 extends P4 {
9+
public function method(parent $x) {}
10+
}
11+
class B4 extends A4 {
12+
public function method(parent $x) {}
13+
}
14+
15+
?>
16+
--EXPECTF--
17+
Fatal error: Declaration of B4::method(A4 $x) must be compatible with A4::method(P4 $x) in %s on line %d
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Use of parent inside a class that has / has no parent (success cases)
3+
--FILE--
4+
<?php
5+
6+
// Legal: A2::parent == P2
7+
class P2 {}
8+
class A2 extends P2 {
9+
public function method(parent $x) {}
10+
}
11+
class B2 extends A2 {
12+
public function method(P2 $x) {}
13+
}
14+
15+
// Legal: B3::parent == A3 is subclass of A3::parent == P3 in covariant position
16+
class P3 {}
17+
class A3 extends P3 {
18+
public function method($x): parent {}
19+
}
20+
class B3 extends A3 {
21+
public function method($x): parent {}
22+
}
23+
24+
?>
25+
===DONE===
26+
--EXPECT--
27+
===DONE===

Zend/tests/use_unlinked_class.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Classes can only be used once they are fully linked
3+
--FILE--
4+
<?php
5+
6+
spl_autoload_register(function($class) {
7+
echo new ReflectionClass(A::class), "\n";
8+
});
9+
10+
class A implements I {
11+
}
12+
13+
?>
14+
--EXPECTF--
15+
Fatal error: During class fetch: Uncaught ReflectionException: Class A does not exist in %s:%d
16+
Stack trace:
17+
#0 %s(%d): ReflectionClass->__construct('A')
18+
#1 [internal function]: {closure}('I')
19+
#2 %s(%d): spl_autoload_call('I')
20+
#3 {main} in %s on line %d

Zend/zend_API.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,7 +2666,7 @@ ZEND_API int zend_disable_function(char *function_name, size_t function_name_len
26662666
}
26672667

26682668
if ((func = zend_hash_str_find_ptr(CG(function_table), function_name, function_name_length))) {
2669-
func->fn_flags &= ~(ZEND_ACC_VARIADIC | ZEND_ACC_HAS_TYPE_HINTS);
2669+
func->fn_flags &= ~(ZEND_ACC_VARIADIC | ZEND_ACC_HAS_TYPE_HINTS | ZEND_ACC_HAS_RETURN_TYPE);
26702670
func->num_args = 0;
26712671
func->arg_info = NULL;
26722672
func->handler = ZEND_FN(display_disabled_function);
@@ -2777,7 +2777,7 @@ static int zend_is_callable_check_class(zend_string *name, zend_class_entry *sco
27772777
*strict_class = 1;
27782778
ret = 1;
27792779
}
2780-
} else if ((ce = zend_lookup_class_ex(name, NULL, 1)) != NULL) {
2780+
} else if ((ce = zend_lookup_class(name)) != NULL) {
27812781
zend_class_entry *scope;
27822782
zend_execute_data *ex = EG(current_execute_data);
27832783

Zend/zend_API.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ typedef struct _zend_fcall_info_cache {
140140
#define ZEND_MODULE_ACTIVATE_D(module) int ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS)
141141
#define ZEND_MODULE_DEACTIVATE_D(module) int ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS)
142142
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) int ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void)
143-
#define ZEND_MODULE_INFO_D(module) void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS)
143+
#define ZEND_MODULE_INFO_D(module) ZEND_COLD void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS)
144144
#define ZEND_MODULE_GLOBALS_CTOR_D(module) void ZEND_MODULE_GLOBALS_CTOR_N(module)(zend_##module##_globals *module##_globals)
145145
#define ZEND_MODULE_GLOBALS_DTOR_D(module) void ZEND_MODULE_GLOBALS_DTOR_N(module)(zend_##module##_globals *module##_globals)
146146

@@ -610,7 +610,7 @@ END_EXTERN_C()
610610
#define RETVAL_EMPTY_STRING() ZVAL_EMPTY_STRING(return_value)
611611
#define RETVAL_RES(r) ZVAL_RES(return_value, r)
612612
#define RETVAL_ARR(r) ZVAL_ARR(return_value, r)
613-
#define RETVAL_EMPTY_ARRAY(r) ZVAL_EMPTY_ARRAY(return_value)
613+
#define RETVAL_EMPTY_ARRAY() ZVAL_EMPTY_ARRAY(return_value)
614614
#define RETVAL_OBJ(r) ZVAL_OBJ(return_value, r)
615615
#define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor)
616616
#define RETVAL_FALSE ZVAL_FALSE(return_value)
@@ -629,7 +629,7 @@ END_EXTERN_C()
629629
#define RETURN_EMPTY_STRING() { RETVAL_EMPTY_STRING(); return; }
630630
#define RETURN_RES(r) { RETVAL_RES(r); return; }
631631
#define RETURN_ARR(r) { RETVAL_ARR(r); return; }
632-
#define RETURN_EMPTY_ARRAY(r) { RETVAL_EMPTY_ARRAY(r); return; }
632+
#define RETURN_EMPTY_ARRAY() { RETVAL_EMPTY_ARRAY(); return; }
633633
#define RETURN_OBJ(r) { RETVAL_OBJ(r); return; }
634634
#define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; }
635635
#define RETURN_FALSE { RETVAL_FALSE; return; }

0 commit comments

Comments
 (0)