add error if __HALT_COMPILER(); is not declared and new test

This commit is contained in:
Greg Beaver 2005-12-08 06:38:26 +00:00
parent dc26e611e4
commit 6ff5c1f974
3 changed files with 17 additions and 1 deletions

View File

@ -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);

View File

@ -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
View 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