Skip to content

Commit 711e2a1

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Check class linking in VERIFY_RETURN_TYPE optimization Simplify travis setup scripts
2 parents c858d17 + f07565b commit 711e2a1

File tree

9 files changed

+34
-17
lines changed

9 files changed

+34
-17
lines changed

.travis.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ env:
5151
- PDO_MYSQL_TEST_USER=travis
5252
- PDO_MYSQL_TEST_PASS=
5353
- PDO_MYSQL_TEST_HOST=127.0.0.1
54+
- PDO_PGSQL_TEST_DSN="pgsql:host=localhost port=5432 dbname=test user=postgres password="
5455
- REPORT_EXIT_STATUS=1
5556
matrix:
5657
- ENABLE_ZTS=0 ENABLE_DEBUG=0
@@ -65,11 +66,8 @@ before_script:
6566
# Compile PHP
6667
- travis_wait ./travis/compile.sh
6768
# Setup Extensions
68-
- . ./travis/ext/mysql/setup.sh
69-
- . ./travis/ext/mysqli/setup.sh
70-
- . ./travis/ext/pdo_mysql/setup.sh
71-
- . ./travis/ext/pgsql/setup.sh
72-
- . ./travis/ext/pdo_pgsql/setup.sh
69+
- ./travis/setup-mysql.sh
70+
- ./travis/setup-pgsql.sh
7371

7472
# Run PHPs run-tests.php
7573
script:

ext/opcache/Optimizer/dfa_pass.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,17 @@ static void zend_ssa_remove_nops(zend_op_array *op_array, zend_ssa *ssa, zend_op
278278
free_alloca(shiftlist, use_heap);
279279
}
280280

281+
static zend_bool safe_instanceof(zend_class_entry *ce1, zend_class_entry *ce2) {
282+
if (ce1 == ce2) {
283+
return 1;
284+
}
285+
if (!(ce1->ce_flags & ZEND_ACC_LINKED)) {
286+
/* This case could be generalized, similarly to unlinked_instanceof */
287+
return 0;
288+
}
289+
return instanceof_function(ce1, ce2);
290+
}
291+
281292
static inline zend_bool can_elide_return_type_check(
282293
zend_op_array *op_array, zend_ssa *ssa, zend_ssa_op *ssa_op) {
283294
zend_arg_info *info = &op_array->arg_info[-1];
@@ -302,7 +313,7 @@ static inline zend_bool can_elide_return_type_check(
302313
}
303314

304315
if (ZEND_TYPE_IS_CLASS(info->type)) {
305-
if (!use_info->ce || !def_info->ce || !instanceof_function(use_info->ce, def_info->ce)) {
316+
if (!use_info->ce || !def_info->ce || !safe_instanceof(use_info->ce, def_info->ce)) {
306317
return 0;
307318
}
308319
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Instanceof checks in VERIFY_RETURN_TYPE optimization may deal with unlinked classes
3+
--FILE--
4+
<?php
5+
interface foo { }
6+
7+
interface biz {}
8+
9+
class qux implements foo {
10+
public function bar(): biz {
11+
$x = $this;
12+
return $x;
13+
}
14+
}
15+
16+
?>
17+
===DONE===
18+
--EXPECT--
19+
===DONE===

travis/ext/curl/setup.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

travis/ext/mysqli/setup.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

travis/ext/pdo_mysql/setup.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

travis/ext/pdo_pgsql/setup.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)