diff options
-rw-r--r-- | ext/spl/spl_fixedarray.c | 7 | ||||
-rw-r--r-- | ext/spl/tests/SplFixedArray__construct_param_array.phpt | 9 | ||||
-rw-r--r-- | ext/spl/tests/SplFixedArray__construct_param_string.phpt | 9 | ||||
-rw-r--r-- | ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt | 13 | ||||
-rw-r--r-- | ext/spl/tests/fixedarray_005.phpt | 10 | ||||
-rw-r--r-- | ext/spl/tests/fixedarray_009.phpt | 10 | ||||
-rw-r--r-- | ext/spl/tests/fixedarray_015.phpt | 40 |
7 files changed, 48 insertions, 50 deletions
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index cd83a17b56..dcac83d60d 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -561,6 +561,13 @@ SPL_METHOD(SplFixedArray, __construct) spl_fixedarray_object *intern; zend_long size = 0; + int rv; + zend_error_handling zeh; + +// zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &zeh TSRMLS_CC); +// rv = zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &size); +// zend_restore_error_handling(&zeh TSRMLS_CC); + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &size) == FAILURE) { return; } diff --git a/ext/spl/tests/SplFixedArray__construct_param_array.phpt b/ext/spl/tests/SplFixedArray__construct_param_array.phpt index 1d78695d4a..aa5933ebdb 100644 --- a/ext/spl/tests/SplFixedArray__construct_param_array.phpt +++ b/ext/spl/tests/SplFixedArray__construct_param_array.phpt @@ -5,8 +5,13 @@ PHPNW Test Fest 2009 - Jordan Hatch --FILE-- <?php -$array = new SplFixedArray( array("string", 1) ); +try { + $array = new SplFixedArray( array("string", 1) ); +} +catch(InvalidArgumentException $iae) { + echo "Ok - ".$iae->getMessage().PHP_EOL; +} ?> --EXPECTF-- -Warning: SplFixedArray::__construct() expects parameter 1 to be integer, array given in %s on line %d
\ No newline at end of file +Ok - SplFixedArray::__construct() expects parameter 1 to be integer, array given
\ No newline at end of file diff --git a/ext/spl/tests/SplFixedArray__construct_param_string.phpt b/ext/spl/tests/SplFixedArray__construct_param_string.phpt index 99742e3eb7..411d7402df 100644 --- a/ext/spl/tests/SplFixedArray__construct_param_string.phpt +++ b/ext/spl/tests/SplFixedArray__construct_param_string.phpt @@ -4,9 +4,14 @@ SplFixedArray::__construct() with string passed as parameter. PHPNW Test Fest 2009 - Jordan Hatch --FILE-- <?php +try { + $array = new SplFixedArray( "string" ); +} +catch(InvalidArgumentException $iae) { + echo "Ok - ".$iae->getMessage().PHP_EOL; +} -$array = new SplFixedArray( "string" ); ?> --EXPECTF-- -Warning: SplFixedArray::__construct() expects parameter 1 to be integer, %unicode_string_optional% given in %s on line %d +Ok - SplFixedArray::__construct() expects parameter 1 to be integer, %unicode_string_optional% given diff --git a/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt b/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt index e91f110cd4..10d4c64a0c 100644 --- a/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt +++ b/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt @@ -4,10 +4,13 @@ Create an SplFixedArray using an SplFixedArray object. Philip Norton philipnorton42@gmail.com --FILE-- <?php -$array = new SplFixedArray(new SplFixedArray(3)); -var_dump($array); +try { + $array = new SplFixedArray(new SplFixedArray(3)); +} +catch(InvalidArgumentException $iae) { + echo "Ok - ".$iae->getMessage().PHP_EOL; +} + ?> --EXPECTF-- -Warning: SplFixedArray::__construct() expects parameter 1 to be integer, object given in %s on line %d -object(SplFixedArray)#1 (0) { -}
\ No newline at end of file +Ok - SplFixedArray::__construct() expects parameter 1 to be integer, object given diff --git a/ext/spl/tests/fixedarray_005.phpt b/ext/spl/tests/fixedarray_005.phpt index fdd78f06a2..72970a9a1f 100644 --- a/ext/spl/tests/fixedarray_005.phpt +++ b/ext/spl/tests/fixedarray_005.phpt @@ -5,8 +5,14 @@ SPL: FixedArray: Trying to instantiate passing object to constructor parameter $b = new stdClass; -$a = new SplFixedArray($b); +try { + $a = new SplFixedArray($b); +} +catch(InvalidArgumentException $iae) { + echo "Ok - ".$iae->getMessage().PHP_EOL; +} + ?> --EXPECTF-- -Warning: SplFixedArray::__construct() expects parameter 1 to be integer, object given in %s on line %d +Ok - SplFixedArray::__construct() expects parameter 1 to be integer, object given diff --git a/ext/spl/tests/fixedarray_009.phpt b/ext/spl/tests/fixedarray_009.phpt index c386fc638e..d67c7ccb69 100644 --- a/ext/spl/tests/fixedarray_009.phpt +++ b/ext/spl/tests/fixedarray_009.phpt @@ -3,8 +3,12 @@ SPL: FixedArray: Trying to instantiate passing string to construtor parameter --FILE-- <?php -$a = new SplFixedArray('FOO'); - +try { + $a = new SplFixedArray('FOO'); +} +catch(InvalidArgumentException $iae) { + echo "Ok - ".$iae->getMessage().PHP_EOL; +} ?> --EXPECTF-- -Warning: SplFixedArray::__construct() expects parameter 1 to be integer, string given in %s on line %d +Ok - SplFixedArray::__construct() expects parameter 1 to be integer, string given diff --git a/ext/spl/tests/fixedarray_015.phpt b/ext/spl/tests/fixedarray_015.phpt index 6e31a42532..f12d83bb39 100644 --- a/ext/spl/tests/fixedarray_015.phpt +++ b/ext/spl/tests/fixedarray_015.phpt @@ -3,47 +3,15 @@ SPL: FixedArray: accessing uninitialized array --FILE-- <?php -$a = new SplFixedArray(''); - -try { - var_dump($a[1]); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; -} -try { - $a[1] = 1; -} catch (Exception $e) { - echo $e->getMessage(), "\n"; -} try { - var_dump(count($a[1])); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; + $a = new SplFixedArray(''); } -try { - var_dump($a->getSize()); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; -} -try { - foreach ($a as $v) { - } -} catch (Exception $e) { - echo $e->getMessage(), "\n"; -} -try { - var_dump($a->setSize(10)); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +catch(InvalidArgumentException $iae) { + echo "Ok - ".$iae->getMessage().PHP_EOL; } echo "Done\n"; ?> --EXPECTF-- -Warning: SplFixedArray::__construct() expects parameter 1 to be integer, string given in %s on line %d -Index invalid or out of range -Index invalid or out of range -Index invalid or out of range -int(0) -bool(true) +Ok - SplFixedArray::__construct() expects parameter 1 to be integer, string given Done |