mirror of
https://github.com/php/php-src.git
synced 2024-12-26 02:10:46 +08:00
add error if __HALT_COMPILER(); is not declared and new test
This commit is contained in:
parent
dc26e611e4
commit
6ff5c1f974
@ -135,7 +135,12 @@ PHP_METHOD(PHP_Archive, mapPhar)
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(halt_constant);
|
||||
zend_get_constant("__COMPILER_HALT_OFFSET__", 24, halt_constant TSRMLS_CC);
|
||||
if (0 == zend_get_constant("__COMPILER_HALT_OFFSET__", 24, halt_constant TSRMLS_CC)) {
|
||||
zval_dtor(halt_constant);
|
||||
FREE_ZVAL(halt_constant);
|
||||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "__HALT_COMPILER(); must be declared in a phar");
|
||||
return;
|
||||
}
|
||||
halt_offset = Z_LVAL(*halt_constant);
|
||||
zval_dtor(halt_constant);
|
||||
FREE_ZVAL(halt_constant);
|
||||
|
@ -10,6 +10,7 @@ PHP_Archive::mapPhar(5, 5);
|
||||
PHP_Archive::mapPhar(5, 'hio');
|
||||
PHP_Archive::mapPhar(5, 'hio', 'hi');
|
||||
PHP_Archive::mapPhar(5, 'hio', true, 5, 5);
|
||||
__HALT_COMPILER();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: PHP_Archive::mapPhar() expects at least 3 parameters, 0 given in %s on line %d
|
||||
|
10
ext/phar/tests/004.phpt
Normal file
10
ext/phar/tests/004.phpt
Normal file
@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
PHP_Archive::mapPhar improper parameters
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) print "skip";?>
|
||||
--FILE--
|
||||
<?php
|
||||
PHP_Archive::mapPhar(5, 'hio', false);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: PHP_Archive::mapPhar(): __HALT_COMPILER(); must be declared in a phar in %s on line %d
|
Loading…
Reference in New Issue
Block a user