Compare commits

...
Author SHA1 Message Date
SVN Migration ca8363be92 This commit was manufactured by cvs2svn to create tag 'php_5_2_5RC1'. 2007-10-18 22:59:44 +00:00
Ilia Alshanetsky 63f4dc835e 5.2.5RC1 2007-10-18 22:59:43 +00:00
Scott MacVicar 3e47b3cb7b MFB53: Fixed bug #43020 (Warning message is missing with shuffle() and more than one argument) 2007-10-18 14:39:08 +00:00
Dmitry Stogov 168f127abb Fixed bug #42722 (display_errors setting ignored for E_PARSE and HTTP 500 page) 2007-10-18 13:11:30 +00:00
Marcus Boerger 2e2a566c15 - BFN 2007-10-18 05:32:50 +00:00
Marcus Boerger 9f6936fc0c - MF53 Fix for #41692, #42703
# Now in correct branch with fixed checkout and so on
2007-10-18 05:26:55 +00:00
Marcus Boerger efc78b635b - Fix test expectation 2007-10-18 04:51:53 +00:00
Marcus Boerger 017fa36d3f - MFB #42654, #42704 2007-10-18 04:49:55 +00:00
Dmitry Stogov c43fe1c6cf Fixed possible crash because of uninitialized value (Zdash Urf) 2007-10-17 12:08:46 +00:00
Dmitry Stogov 82264b0b45 Fixed bug #42637 (SoapFault : Only http and https are allowed) 2007-10-17 11:17:46 +00:00
Antony Dovgal 7a9cd0a4fd MFH 2007-10-17 08:19:50 +00:00
Antony Dovgal 36e950eb5f avoid double free and use zval_dtor() where neccessary 2007-10-16 13:20:29 +00:00
Andrey Hristov c8f8766461 MFB5_3 : Shadowing of params bring undefined results. 2007-10-16 13:00:32 +00:00
Raghubansh Kumar 7a97b74637 New testcases for array_flip() function 2007-10-15 06:29:37 +00:00
Raghubansh Kumar 92642d0189 New testcases for array_reverse() function 2007-10-15 06:09:27 +00:00
Hannes Magnusson a029117eb5 MFH: fix typo and remove dots in error message 2007-10-13 11:35:35 +00:00
Ilia Alshanetsky accfde57ca MFB: Fixed bug #42917 (PDO::FETCH_KEY_PAIR doesn't work with setFetchMode) 2007-10-11 20:56:22 +00:00
Derick Rethans 94a3bb327e - Updated to version 2007.8 2007-10-11 18:54:37 +00:00
Raghubansh Kumar d7e424acbe fix test (temp. file name) 2007-10-11 11:53:16 +00:00
Jani Taskinen 979e8b5896 MFB53 2007-10-11 09:33:53 +00:00
Jani Taskinen 3c9eb61d04 MF53 2007-10-11 08:28:02 +00:00
Robert Thompson 98505945f2 Fix for bug 41899, safe mode and relative paths with Solaris's broken getcwd(). 2007-10-10 23:54:39 +00:00
Jani Taskinen 6f128d2dd7 - Generated with more recent re2c version 2007-10-10 09:28:51 +00:00
Ilia Alshanetsky 00f18d764a MFB: Fixed bug #42869 (automatic session id insertion adds sessions id to
non-local forms)
2007-10-10 00:35:52 +00:00
Scott MacVicar 6928bdc6bf MFH: Add constant to allow setting of character set with mysqli_options prior to connection. 2007-10-09 16:56:38 +00:00
Raghubansh Kumar 2a078d14c9 New testcases for strip_tags() function 2007-10-09 12:47:00 +00:00
Raghubansh Kumar 1993c9a384 fix test 2007-10-09 12:19:27 +00:00
Raghubansh Kumar ecf81d1529 fix tests 2007-10-09 12:12:19 +00:00
Raghubansh Kumar bf428e90a5 fix tests 2007-10-09 10:56:45 +00:00
Scott MacVicar 7deeb54fe1 MFH: Fix expand_filepath when including relative files, ideally you should test your code... 2007-10-09 10:06:34 +00:00
Jani Taskinen 6d078cea10 MFH: ws + cs 2007-10-09 08:40:47 +00:00
Raghubansh Kumar fdf4c22696 fix tests 2007-10-09 06:18:47 +00:00
Raghubansh Kumar be49c27d17 more tests for fseek(), ftell() & rewind() for win32 2007-10-09 04:55:14 +00:00
Raghubansh Kumar 0c9f9f8ef9 fix tests 2007-10-09 04:07:24 +00:00
Andrey Hristov 8cc2f5d576 News entry 2007-10-08 18:27:18 +00:00
Andrey Hristov 3f6b49a340 Fix for bug #42890 Constant "LIST" defined by mysqlclient and c-client 2007-10-08 18:25:52 +00:00
Raghubansh Kumar 393a686507 fix test 2007-10-08 16:02:55 +00:00
Raghubansh Kumar b8e0f7e78a fix test 2007-10-08 15:44:26 +00:00
Raghubansh Kumar 40098256fb fix tests 2007-10-08 15:36:01 +00:00
Raghubansh Kumar 50a4e50d03 New testcases for strtr() function 2007-10-08 15:19:56 +00:00
Raghubansh Kumar 99d99a0ba0 New testcases for get_html_translation_table() function 2007-10-08 15:19:27 +00:00
Raghubansh Kumar f075e78ac1 fix test 2007-10-08 06:19:11 +00:00
Robert Thompson 477e2b315b Fix for bug 41822 and 41899. expand_filepath() will now return a relative path under the specific situation where getcwd() returns NULL and the file is
still readable.  As far as I have been able to tell, this fix only applies to the Solaris OS where files in directories with (--x) cannot getcwd().
2007-10-08 02:49:26 +00:00
Antony Dovgal 98599a1c23 MFH: fix ws & folding 2007-10-06 21:35:53 +00:00
Raghubansh Kumar ea8fc31bf3 New testcases for setlocale() function 2007-10-05 19:30:51 +00:00
Raghubansh Kumar b84873aa96 New testcases for nl2br() function 2007-10-05 18:44:35 +00:00
Raghubansh Kumar 7cf81e0fe0 New testcases for strrpos() function 2007-10-05 18:31:51 +00:00
Raghubansh Kumar 620b1c63d0 New testcases for str_split() function 2007-10-05 18:16:34 +00:00
Raghubansh Kumar 2a05dfadb2 New testcases for vsprintf() function 2007-10-05 18:07:28 +00:00
Jani Taskinen 5a8c9a7d1c MFH: fix test 2007-10-05 14:57:51 +00:00
Nuno Lopes e1a402b6da allow lcov 1.6 2007-10-05 14:51:36 +00:00
Ilia Alshanetsky f9137cddf6 BFN 2007-10-04 23:26:04 +00:00
Ilia Alshanetsky 07710a5fb9 MFB: Fixed bug #42817 (clone() on a non-object does not result in a fatal
error)
2007-10-04 23:23:43 +00:00
Jani Taskinen 1be447eb95 MFH: Removed ending dots from error messages 2007-10-04 13:31:11 +00:00
Ilia Alshanetsky 91e99495af MFB: Fixed bug #42783 (pg_insert() does not accept an empty list for
insertion)
2007-10-03 23:31:58 +00:00
Michael Wallner b260f03830 MFH: fix CURLOPT_TIMEOUT_MS support 2007-10-03 20:34:48 +00:00
Dmitry Stogov 0cd4039af2 Fixed bug #42818 ($foo = clone(array()); leaks memory) 2007-10-03 09:47:25 +00:00
Dmitry Stogov c7047381f5 Fixed bug #42772 (Storing $this in a static var fails while handling a cast to string) 2007-10-03 08:02:19 +00:00
Stanislav Malyshev f422acca26 add html* utf fix 2007-10-03 05:03:12 +00:00
Stanislav Malyshev ecc9d28fed add test with invalid sequences 2007-10-03 04:58:41 +00:00
Stanislav Malyshev 5e82a38f0a do not accept partial multibyte sequences in html* functions 2007-10-03 04:53:05 +00:00
Antony Dovgal 63b3528cb1 improved recursion detection in array_walk()
fixes #42752, though the leaks are still there
2007-10-02 10:04:13 +00:00
Ilia Alshanetsky 139996e1ac MFB: Added test for bug #42785 2007-10-01 15:33:21 +00:00
Ilia Alshanetsky f89aae49a7 MFB: Fixed bug #42785 (json_encode() formats doubles according to locale
rather then following standard syntax).
2007-10-01 15:23:15 +00:00
Ilia Alshanetsky 94eb3ed91b MFB: Fixed typo in previous patch 2007-10-01 15:00:15 +00:00
Ilia Alshanetsky 191bf235ed MFB: Refactor code to make fixes for coverity issues #385 and #386 a bit
more obvious
2007-10-01 14:53:01 +00:00
Antony Dovgal 7d889d818a fix test 2007-10-01 10:41:36 +00:00
Antony Dovgal d70e63458f fix tests 2007-10-01 10:25:50 +00:00
Antony Dovgal 23d9af29d7 these dots exist since PHP3
even though Jani removed them in 5_3, I can't see how they can cause any BUGS
2007-10-01 10:22:43 +00:00
Pierre Joye 73219c9cb0 - add notice about glob regression (Lukas) 2007-10-01 08:14:03 +00:00
Raghubansh Kumar e538e493d7 smaller tests already exist 2007-09-29 17:21:41 +00:00
Raghubansh Kumar 2770262bad New testcases for sprintf() function 2007-09-29 14:13:53 +00:00
Raghubansh Kumar 69158b5e18 New testcases for chunk_split() function 2007-09-29 12:55:34 +00:00
Raghubansh Kumar f0435592a0 New testcases for stripos() function 2007-09-29 09:19:43 +00:00
Raghubansh Kumar 6eaef0712e New testcases for strrchr() function 2007-09-29 09:18:07 +00:00
Raghubansh Kumar 64f7dafa74 New testcases for join() function 2007-09-29 09:10:18 +00:00
Raghubansh Kumar 16242cd2df New testcases for htmlspecialchars_decode() function 2007-09-29 09:00:48 +00:00
Johannes Schlüter 11d5f9c7c4 - MFH: Fix type in example 2007-09-28 22:04:47 +00:00
Ilia Alshanetsky 3447b26334 MFB: Fixed coverity issue #470 Unitialized integer value used inside
zend_ini_boolean_displayer_cb
2007-09-27 17:27:15 +00:00
Jani Taskinen 12760053c1 missing folding tag 2007-09-27 16:42:11 +00:00
Jani Taskinen 52095f58a5 MFH: use Z_STR* macros 2007-09-27 16:29:27 +00:00
Jani Taskinen b024bedbdb MFH: ws 2007-09-27 16:00:20 +00:00
Jani Taskinen 5cb0b7609a MFH: ws + cs (to keep in sync with HEAD/PHP_5_3 only!) 2007-09-27 15:54:49 +00:00
Jani Taskinen 2c841333ee ws + cs fixes 2007-09-27 13:15:09 +00:00
Antony Dovgal 474f6eef5e MFH: fix coverity issue #412 2007-09-27 09:19:06 +00:00
Antony Dovgal eb2659c7b2 MFH: fix coverity issue #411 2007-09-27 09:15:20 +00:00
360 changed files with 36210 additions and 1464 deletions

No files matched your search

+26 -1
View File
@@ -1,6 +1,6 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 20??, PHP 5.2.5
18 Oct 2007, PHP 5.2.5RC1
- Upgraded PCRE to version 7.3 (Nuno)
- Added optional parameter $provide_object to debug_backtrace(). (Sebastian)
- Added alpha support for imagefilter() IMG_FILTER_COLORIZE. (Pierre)
@@ -9,6 +9,7 @@ PHP NEWS
array_uintersect_assoc(), array_diff_key(), array_diff_assoc() and
array_udiff_assoc(). (Dmitry)
- Fixed possible crash in ext/soap because of uninitialized value. (Zdash Urf)
- Fixed regression in glob() when enforcing safe_mode/open_basedir checks on
paths containing '*'. (Ilia)
- Fixed "mail.force_extra_parameters" php.ini directive not to be modifiable
@@ -29,12 +30,36 @@ PHP NEWS
implementations of the fnmatch(), setlocale() and glob() functions.
Reported by Laurent gaffie. (Ilia)
- Fixed imagerectangle regression with 1x1 rectangle (libgd #106). (Pierre)
- Fixed htmlentities/htmlspecialchars not to accept partial multibyte
sequences. (Stas)
- Fixed bug #43020 (Warning message is missing with shuffle() and more
than one argument). (Scott)
- Fixed bug #42917 (PDO::FETCH_KEY_PAIR doesn't work with setFetchMode).
(Ilia)
- Fixed bug #42890 (Constant "LIST" defined by mysqlclient and c-client).
(Andrey)
- Fixed bug #42869 (automatic session id insertion adds sessions id to
non-local forms). (Ilia)
- Fixed bug #42818 ($foo = clone(array()); leaks memory). (Dmitry)
- Fixed bug #42817 (clone() on a non-object does not result in a fatal
error). (Ilia)
- Fixed bug #42785 (json_encode() formats doubles according to locale rather
then following standard syntax). (Ilia)
- Fixed bug #42783 (pg_insert() does not accept an empty list for
insertion). (Ilia)
- Fixed bug #42772 (Storing $this in a static var fails while handling a cast
to string). (Dmitry)
- Fixed bug #42767 (highlight_string() truncates trailing comment). (Ilia)
- Fixed bug #42739 (mkdir() doesn't like a trailing slash when safe_mode is
enabled). (Ilia)
- Fixed bug #42703 (Exception raised in an iterator::current() causes segfault
in FilterIterator) (Marcus)
- Fixed bug #42699 (PHP_SELF duplicates path). (Dmitry)
- Fixed bug #42654 (RecursiveIteratorIterator modifies only part of leaves)
(Marcus)
- Fixed bug #42643 (CLI segfaults if using ATTR_PERSISTENT). (Ilia)
- Fixed bug #42637 (SoapFault : Only http and https are allowed). (Bill Moran)
- Fixed bug #42629 (Dynamically loaded PHP extensions need symbols exported
on MacOSX). (jdolecek at NetBSD dot org)
- Fixed bug #42627 (bz2 extension fails to build with -fno-common).
+1 -1
View File
@@ -70,7 +70,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lsz",
/* Gets an object of class specified by my_ce, and an optional double. */
zval *obj;
double d = 0.5;
zend_class_entry my_ce;
zend_class_entry *my_ce;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|d",
&obj, my_ce, &d) == FAILURE) {
return;
+15
View File
@@ -172,6 +172,21 @@ Items from the NEWS file explained
from your error handler in order to populate $php_errormsg. This allows
you to fine-grain the levels of the messages stored.
==============================
Regressions introduced/fixed
==============================
- In version 5.2.4 a security fix caused a regression for patterns of
the form "/foo/*/bar/*". Since version 5.2.5 instead of raising a warning the
glob() function will return false when openbase_dir restrictions are violated.
#See http://bugs.php.net/bug.php?id=41655
The warning that used to be raised looked like something as follows:
Warning: glob() [function.glob]: Unable to access /foo/*/bar/* in /foo.php on line xxx
#See http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.169&r2=1.170
The patch can safely be applied to PHP 5.2.4 as well.
==============================
Backwards incompatible changes
+1 -3
View File
@@ -6,8 +6,6 @@ error_reporting=4095
<?php
$a = clone 0;
$a[0]->b = 0;
echo "ok\n";
?>
--EXPECTF--
Warning: __clone method called on non-object in %sbug36071.php on line 2
ok
Fatal error: __clone method called on non-object in %sbug36071.php on line 2
+18
View File
@@ -0,0 +1,18 @@
--TEST--
Bug #42772 (Storing $this in a static var fails while handling a cast to string)
--FILE--
<?php
class Foo {
static public $foo;
function __toString() {
self::$foo = $this;
return 'foo';
}
}
$foo = (string)new Foo();
var_dump(Foo::$foo);
?>
--EXPECT--
object(Foo)#1 (0) {
}
+9
View File
@@ -0,0 +1,9 @@
--TEST--
Bug #42817 (clone() on a non-object does not result in a fatal error)
--FILE--
<?php
$a = clone(null);
array_push($a->b, $c);
?>
--EXPECTF--
Fatal error: __clone method called on non-object in %sbug42817.php on line 2
+9
View File
@@ -0,0 +1,9 @@
--TEST--
Bug #42818 ($foo = clone(array()); leaks memory)
--FILE--
<?php
$foo = clone(array());
?>
--EXPECTF--
Fatal error: __clone method called on non-object in %sbug42818.php on line 2
+54 -51
View File
@@ -26,7 +26,7 @@
#include "zend_operators.h"
#include "zend_strtod.h"
static HashTable *registered_zend_ini_directives;
static HashTable *registered_zend_ini_directives;
#define NO_VALUE_PLAINTEXT "no value"
#define NO_VALUE_HTML "<i>no value</i>"
@@ -51,7 +51,7 @@ static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage TSRMLS
zend_try {
/* even if on_modify bails out, we have to continue on with restoring,
since there can be allocated variables that would be freed on MM shutdown
and would lead to memory corruption later ini entry is modified again */
and would lead to memory corruption later ini entry is modified again */
ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC);
} zend_end_try();
}
@@ -84,7 +84,7 @@ ZEND_API int zend_ini_startup(TSRMLS_D) /* {{{ */
EG(ini_directives) = registered_zend_ini_directives;
EG(modified_ini_directives) = NULL;
if (zend_hash_init_ex(registered_zend_ini_directives, 100, NULL, NULL, 1, 0)==FAILURE) {
if (zend_hash_init_ex(registered_zend_ini_directives, 100, NULL, NULL, 1, 0) == FAILURE) {
return FAILURE;
}
return SUCCESS;
@@ -126,7 +126,7 @@ ZEND_API int zend_copy_ini_directives(TSRMLS_D) /* {{{ */
EG(modified_ini_directives) = NULL;
EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
if (zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, NULL, 1, 0)==FAILURE) {
if (zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, NULL, 1, 0) == FAILURE) {
return FAILURE;
}
zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, NULL, &ini_entry, sizeof(zend_ini_entry));
@@ -139,15 +139,15 @@ static int ini_key_compare(const void *a, const void *b TSRMLS_DC) /* {{{ */
{
Bucket *f;
Bucket *s;
f = *((Bucket **) a);
s = *((Bucket **) b);
if (f->nKeyLength==0 && s->nKeyLength==0) { /* both numeric */
if (f->nKeyLength == 0 && s->nKeyLength == 0) { /* both numeric */
return ZEND_NORMALIZE_BOOL(f->nKeyLength - s->nKeyLength);
} else if (f->nKeyLength==0) { /* f is numeric, s is not */
} else if (f->nKeyLength == 0) { /* f is numeric, s is not */
return -1;
} else if (s->nKeyLength==0) { /* s is numeric, f is not */
} else if (s->nKeyLength == 0) { /* s is numeric, f is not */
return 1;
} else { /* both strings */
return zend_binary_strcasecmp(f->arKey, f->nKeyLength, s->arKey, s->nKeyLength);
@@ -189,15 +189,15 @@ ZEND_API int zend_register_ini_entries(zend_ini_entry *ini_entry, int module_num
while (p->name) {
p->module_number = module_number;
config_directive_success = 0;
if (zend_hash_add(directives, p->name, p->name_length, p, sizeof(zend_ini_entry), (void **) &hashed_ini_entry)==FAILURE) {
if (zend_hash_add(directives, p->name, p->name_length, p, sizeof(zend_ini_entry), (void **) &hashed_ini_entry) == FAILURE) {
zend_unregister_ini_entries(module_number TSRMLS_CC);
return FAILURE;
}
if ((zend_get_configuration_directive(p->name, p->name_length, &default_value))==SUCCESS) {
if ((zend_get_configuration_directive(p->name, p->name_length, &default_value)) == SUCCESS) {
if (!hashed_ini_entry->on_modify
|| hashed_ini_entry->on_modify(hashed_ini_entry, default_value.value.str.val, default_value.value.str.len, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC)==SUCCESS) {
hashed_ini_entry->value = default_value.value.str.val;
hashed_ini_entry->value_length = default_value.value.str.len;
|| hashed_ini_entry->on_modify(hashed_ini_entry, Z_STRVAL(default_value), Z_STRLEN(default_value), hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC) == SUCCESS) {
hashed_ini_entry->value = Z_STRVAL(default_value);
hashed_ini_entry->value_length = Z_STRLEN(default_value);
config_directive_success = 1;
}
}
@@ -247,7 +247,7 @@ ZEND_API int zend_alter_ini_entry_ex(char *name, uint name_length, char *new_val
zend_bool modified;
TSRMLS_FETCH();
if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry)==FAILURE) {
if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == FAILURE) {
return FAILURE;
}
@@ -277,7 +277,7 @@ ZEND_API int zend_alter_ini_entry_ex(char *name, uint name_length, char *new_val
duplicate = estrndup(new_value, new_value_length);
if (!ini_entry->on_modify
|| ini_entry->on_modify(ini_entry, duplicate, new_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC)==SUCCESS) {
|| ini_entry->on_modify(ini_entry, duplicate, new_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC) == SUCCESS) {
if (modified && ini_entry->orig_value != ini_entry->value) { /* we already changed the value, free the changed value */
efree(ini_entry->value);
}
@@ -296,8 +296,8 @@ ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage) /*
zend_ini_entry *ini_entry;
TSRMLS_FETCH();
if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry)==FAILURE ||
(stage == ZEND_INI_STAGE_RUNTIME && (ini_entry->modifiable & ZEND_INI_USER) == 0)) {
if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == FAILURE ||
(stage == ZEND_INI_STAGE_RUNTIME && (ini_entry->modifiable & ZEND_INI_USER) == 0)) {
return FAILURE;
}
@@ -305,7 +305,7 @@ ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage) /*
zend_restore_ini_entry_cb(ini_entry, stage TSRMLS_CC);
zend_hash_del(EG(modified_ini_directives), name, name_length);
}
return SUCCESS;
}
/* }}} */
@@ -314,7 +314,7 @@ ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*di
{
zend_ini_entry *ini_entry;
if (zend_hash_find(registered_zend_ini_directives, name, name_length, (void **) &ini_entry)==FAILURE) {
if (zend_hash_find(registered_zend_ini_directives, name, name_length, (void **) &ini_entry) == FAILURE) {
return FAILURE;
}
@@ -332,7 +332,7 @@ ZEND_API long zend_ini_long(char *name, uint name_length, int orig) /* {{{ */
zend_ini_entry *ini_entry;
TSRMLS_FETCH();
if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry)==SUCCESS) {
if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == SUCCESS) {
if (orig && ini_entry->modified) {
return (ini_entry->orig_value ? strtol(ini_entry->orig_value, NULL, 0) : 0);
} else if (ini_entry->value) {
@@ -349,7 +349,7 @@ ZEND_API double zend_ini_double(char *name, uint name_length, int orig) /* {{{ *
zend_ini_entry *ini_entry;
TSRMLS_FETCH();
if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry)==SUCCESS) {
if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == SUCCESS) {
if (orig && ini_entry->modified) {
return (double) (ini_entry->orig_value ? zend_strtod(ini_entry->orig_value, NULL) : 0.0);
} else if (ini_entry->value) {
@@ -366,7 +366,7 @@ ZEND_API char *zend_ini_string(char *name, uint name_length, int orig) /* {{{ */
zend_ini_entry *ini_entry;
TSRMLS_FETCH();
if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry)==SUCCESS) {
if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == SUCCESS) {
if (orig && ini_entry->modified) {
return ini_entry->orig_value;
} else {
@@ -378,7 +378,7 @@ ZEND_API char *zend_ini_string(char *name, uint name_length, int orig) /* {{{ */
}
/* }}} */
#if TONY_20070307
#if TONY_20070307
static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type) /* {{{ */
{
if (ini_entry->displayer) {
@@ -387,18 +387,18 @@ static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type) /* {{{ */
char *display_string;
uint display_string_length;
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
if (ini_entry->orig_value) {
display_string = ini_entry->orig_value;
display_string_length = ini_entry->orig_value_length;
} else {
if (zend_uv.html_errors) {
display_string = NO_VALUE_HTML;
display_string_length = sizeof(NO_VALUE_HTML)-1;
display_string_length = sizeof(NO_VALUE_HTML) - 1;
} else {
display_string = NO_VALUE_PLAINTEXT;
display_string_length = sizeof(NO_VALUE_PLAINTEXT)-1;
}
display_string_length = sizeof(NO_VALUE_PLAINTEXT) - 1;
}
}
} else if (ini_entry->value && ini_entry->value[0]) {
display_string = ini_entry->value;
@@ -406,11 +406,11 @@ static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type) /* {{{ */
} else {
if (zend_uv.html_errors) {
display_string = NO_VALUE_HTML;
display_string_length = sizeof(NO_VALUE_HTML)-1;
display_string_length = sizeof(NO_VALUE_HTML) - 1;
} else {
display_string = NO_VALUE_PLAINTEXT;
display_string_length = sizeof(NO_VALUE_PLAINTEXT)-1;
}
display_string_length = sizeof(NO_VALUE_PLAINTEXT) - 1;
}
}
ZEND_WRITE(display_string, display_string_length);
}
@@ -423,7 +423,7 @@ ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */
int value, tmp_value_len;
char *tmp_value;
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
tmp_value_len = ini_entry->orig_value_length;
} else if (ini_entry->value) {
@@ -434,18 +434,20 @@ ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */
tmp_value_len = 0;
}
if (tmp_value_len == 4 && strcasecmp(tmp_value, "true") == 0) {
value = 1;
} else if (tmp_value_len == 3 && strcasecmp(tmp_value, "yes") == 0) {
value = 1;
} else if (tmp_value_len == 2 && strcasecmp(tmp_value, "on") == 0) {
value = 1;
} else if (value) {
value = atoi(tmp_value);
if (tmp_value) {
if (tmp_value_len == 4 && strcasecmp(tmp_value, "true") == 0) {
value = 1;
} else if (tmp_value_len == 3 && strcasecmp(tmp_value, "yes") == 0) {
value = 1;
} else if (tmp_value_len == 2 && strcasecmp(tmp_value, "on") == 0) {
value = 1;
} else {
value = atoi(tmp_value);
}
} else {
value = 0;
}
if (value) {
ZEND_PUTS("On");
} else {
@@ -458,7 +460,7 @@ ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */
{
char *value;
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ini_entry->orig_value;
} else if (ini_entry->value) {
value = ini_entry->value;
@@ -470,13 +472,13 @@ ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */
zend_printf("<font style=\"color: %s\">%s</font>", value, value);
} else {
ZEND_PUTS(value);
}
}
} else {
if (zend_uv.html_errors) {
ZEND_PUTS(NO_VALUE_HTML);
} else {
ZEND_PUTS(NO_VALUE_PLAINTEXT);
}
}
}
}
/* }}} */
@@ -485,7 +487,7 @@ ZEND_INI_DISP(display_link_numbers) /* {{{ */
{
char *value;
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ini_entry->orig_value;
} else if (ini_entry->value) {
value = ini_entry->value;
@@ -494,7 +496,7 @@ ZEND_INI_DISP(display_link_numbers) /* {{{ */
}
if (value) {
if (atoi(value)==-1) {
if (atoi(value) == -1) {
ZEND_PUTS("Unlimited");
} else {
zend_printf("%s", value);
@@ -517,15 +519,15 @@ ZEND_API ZEND_INI_MH(OnUpdateBool) /* {{{ */
p = (zend_bool *) (base+(size_t) mh_arg1);
if (new_value_length==2 && strcasecmp("on", new_value)==0) {
if (new_value_length == 2 && strcasecmp("on", new_value) == 0) {
*p = (zend_bool) 1;
}
else if (new_value_length==3 && strcasecmp("yes", new_value)==0) {
}
else if (new_value_length == 3 && strcasecmp("yes", new_value) == 0) {
*p = (zend_bool) 1;
}
else if (new_value_length==4 && strcasecmp("true", new_value)==0) {
}
else if (new_value_length == 4 && strcasecmp("true", new_value) == 0) {
*p = (zend_bool) 1;
}
}
else {
*p = (zend_bool) atoi(new_value);
}
@@ -549,6 +551,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */
*p = zend_atoi(new_value, new_value_length);
return SUCCESS;
}
/* }}} */
ZEND_API ZEND_INI_MH(OnUpdateLongGEZero)
{
+15 -6
View File
@@ -2531,7 +2531,7 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)
zend_object_clone_obj_t clone_call;
if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {
zend_error(E_WARNING, "__clone method called on non-object");
zend_error_noreturn(E_ERROR, "__clone method called on non-object");
EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr);
EX_T(opline->result.u.var).var.ptr->refcount++;
FREE_OP1_IF_VAR();
@@ -2727,9 +2727,11 @@ ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY)
zval *expr = GET_OP1_ZVAL_PTR(BP_VAR_R);
zval *result = &EX_T(opline->result.u.var).tmp_var;
*result = *expr;
if (!IS_OP1_TMP_FREE()) {
zendi_zval_copy_ctor(*result);
if (opline->extended_value != IS_STRING) {
*result = *expr;
if (!IS_OP1_TMP_FREE()) {
zendi_zval_copy_ctor(*result);
}
}
switch (opline->extended_value) {
case IS_NULL:
@@ -2748,10 +2750,17 @@ ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY)
zval var_copy;
int use_copy;
zend_make_printable_zval(result, &var_copy, &use_copy);
zend_make_printable_zval(expr, &var_copy, &use_copy);
if (use_copy) {
zval_dtor(result);
*result = var_copy;
if (IS_OP1_TMP_FREE()) {
FREE_OP1();
}
} else {
*result = *expr;
if (!IS_OP1_TMP_FREE()) {
zendi_zval_copy_ctor(*result);
}
}
break;
}
+61 -25
View File
@@ -1837,7 +1837,7 @@ static int ZEND_CLONE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zend_object_clone_obj_t clone_call;
if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {
zend_error(E_WARNING, "__clone method called on non-object");
zend_error_noreturn(E_ERROR, "__clone method called on non-object");
EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr);
EX_T(opline->result.u.var).var.ptr->refcount++;
@@ -1895,9 +1895,11 @@ static int ZEND_CAST_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zval *expr = &opline->op1.u.constant;
zval *result = &EX_T(opline->result.u.var).tmp_var;
*result = *expr;
if (!0) {
zendi_zval_copy_ctor(*result);
if (opline->extended_value != IS_STRING) {
*result = *expr;
if (!0) {
zendi_zval_copy_ctor(*result);
}
}
switch (opline->extended_value) {
case IS_NULL:
@@ -1916,10 +1918,17 @@ static int ZEND_CAST_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zval var_copy;
int use_copy;
zend_make_printable_zval(result, &var_copy, &use_copy);
zend_make_printable_zval(expr, &var_copy, &use_copy);
if (use_copy) {
zval_dtor(result);
*result = var_copy;
if (0) {
}
} else {
*result = *expr;
if (!0) {
zendi_zval_copy_ctor(*result);
}
}
break;
}
@@ -4403,7 +4412,7 @@ static int ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zend_object_clone_obj_t clone_call;
if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {
zend_error(E_WARNING, "__clone method called on non-object");
zend_error_noreturn(E_ERROR, "__clone method called on non-object");
EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr);
EX_T(opline->result.u.var).var.ptr->refcount++;
@@ -4461,9 +4470,11 @@ static int ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zval *expr = _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
zval *result = &EX_T(opline->result.u.var).tmp_var;
*result = *expr;
if (!1) {
zendi_zval_copy_ctor(*result);
if (opline->extended_value != IS_STRING) {
*result = *expr;
if (!1) {
zendi_zval_copy_ctor(*result);
}
}
switch (opline->extended_value) {
case IS_NULL:
@@ -4482,10 +4493,17 @@ static int ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zval var_copy;
int use_copy;
zend_make_printable_zval(result, &var_copy, &use_copy);
zend_make_printable_zval(expr, &var_copy, &use_copy);
if (use_copy) {
zval_dtor(result);
*result = var_copy;
if (1) {
zval_dtor(free_op1.var);
}
} else {
*result = *expr;
if (!1) {
zendi_zval_copy_ctor(*result);
}
}
break;
}
@@ -7541,7 +7559,7 @@ static int ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zend_object_clone_obj_t clone_call;
if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {
zend_error(E_WARNING, "__clone method called on non-object");
zend_error_noreturn(E_ERROR, "__clone method called on non-object");
EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr);
EX_T(opline->result.u.var).var.ptr->refcount++;
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
@@ -7599,9 +7617,11 @@ static int ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zval *expr = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
zval *result = &EX_T(opline->result.u.var).tmp_var;
*result = *expr;
if (!0) {
zendi_zval_copy_ctor(*result);
if (opline->extended_value != IS_STRING) {
*result = *expr;
if (!0) {
zendi_zval_copy_ctor(*result);
}
}
switch (opline->extended_value) {
case IS_NULL:
@@ -7620,10 +7640,17 @@ static int ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zval var_copy;
int use_copy;
zend_make_printable_zval(result, &var_copy, &use_copy);
zend_make_printable_zval(expr, &var_copy, &use_copy);
if (use_copy) {
zval_dtor(result);
*result = var_copy;
if (0) {
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
}
} else {
*result = *expr;
if (!0) {
zendi_zval_copy_ctor(*result);
}
}
break;
}
@@ -14692,7 +14719,7 @@ static int ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zend_object_clone_obj_t clone_call;
if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {
zend_error(E_WARNING, "__clone method called on non-object");
zend_error_noreturn(E_ERROR, "__clone method called on non-object");
EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr);
EX_T(opline->result.u.var).var.ptr->refcount++;
@@ -19604,7 +19631,7 @@ static int ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zend_object_clone_obj_t clone_call;
if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {
zend_error(E_WARNING, "__clone method called on non-object");
zend_error_noreturn(E_ERROR, "__clone method called on non-object");
EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr);
EX_T(opline->result.u.var).var.ptr->refcount++;
@@ -19662,9 +19689,11 @@ static int ZEND_CAST_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zval *expr = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC);
zval *result = &EX_T(opline->result.u.var).tmp_var;
*result = *expr;
if (!0) {
zendi_zval_copy_ctor(*result);
if (opline->extended_value != IS_STRING) {
*result = *expr;
if (!0) {
zendi_zval_copy_ctor(*result);
}
}
switch (opline->extended_value) {
case IS_NULL:
@@ -19683,10 +19712,17 @@ static int ZEND_CAST_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zval var_copy;
int use_copy;
zend_make_printable_zval(result, &var_copy, &use_copy);
zend_make_printable_zval(expr, &var_copy, &use_copy);
if (use_copy) {
zval_dtor(result);
*result = var_copy;
if (0) {
}
} else {
*result = *expr;
if (!0) {
zendi_zval_copy_ctor(*result);
}
}
break;
}
+2 -2
View File
@@ -42,7 +42,7 @@ AC_CONFIG_HEADER(main/php_config.h)
PHP_MAJOR_VERSION=5
PHP_MINOR_VERSION=2
PHP_RELEASE_VERSION=5
PHP_EXTRA_VERSION="-dev"
PHP_EXTRA_VERSION="RC1"
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
@@ -646,7 +646,7 @@ if test "$PHP_GCOV" = "yes"; then
AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
fi
ltp_version_list="1.5"
ltp_version_list="1.5 1.6"
AC_CHECK_PROG(LTP, lcov, lcov)
AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
+7 -7
View File
@@ -174,7 +174,7 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC);
} \
\
if (!php_memnstr(str, tmp_url->path, strlen(tmp_url->path), str + len)) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL '%s' contains unencoded control characters.", str); \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL '%s' contains unencoded control characters", str); \
php_url_free(tmp_url); \
php_curl_ret(__ret); \
} \
@@ -387,7 +387,7 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERPWD);
REGISTER_CURL_CONSTANT(CURLOPT_RANGE);
REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT);
#ifdef CURLOPT_TIMEOUT_MS
#if LIBCURL_VERSION_NUM > 0x071002
REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT_MS);
#endif
REGISTER_CURL_CONSTANT(CURLOPT_POSTFIELDS);
@@ -433,7 +433,7 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLOPT_RANDOM_FILE);
REGISTER_CURL_CONSTANT(CURLOPT_EGDSOCKET);
REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT);
#ifdef CURLOPT_CONNECTTIMEOUT_MS
#if LIBCURL_VERSION_NUM > 0x071002
REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT_MS);
#endif
REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYPEER);
@@ -980,7 +980,7 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
strlcpy(buf, Z_STRVAL_P(retval), Z_STRLEN_P(retval));
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "User handler '%s' did not return a string.", Z_STRVAL_P(func));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "User handler '%s' did not return a string", Z_STRVAL_P(func));
}
zval_ptr_dtor(&argv[0]);
@@ -1233,7 +1233,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
case CURLOPT_MUTE:
#endif
case CURLOPT_TIMEOUT:
#ifdef CURLOPT_TIMEOUT_MS
#if LIBCURL_VERSION_NUM > 0x071002
case CURLOPT_TIMEOUT_MS:
#endif
case CURLOPT_FTP_USE_EPSV:
@@ -1252,7 +1252,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
case CURLOPT_FRESH_CONNECT:
case CURLOPT_FORBID_REUSE:
case CURLOPT_CONNECTTIMEOUT:
#ifdef CURLOPT_CONNECTTIMEOUT_MS
#if LIBCURL_VERSION_NUM > 0x071002
case CURLOPT_CONNECTTIMEOUT_MS:
#endif
case CURLOPT_SSL_VERIFYHOST:
@@ -1645,7 +1645,7 @@ PHP_FUNCTION(curl_setopt_array)
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **)&entry, &pos) == SUCCESS) {
if (zend_hash_get_current_key_ex(Z_ARRVAL_P(arr), &string_key, &str_key_len, &option, 0, &pos) == HASH_KEY_IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array keys must be CURLOPT constants or equivalent interger values.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array keys must be CURLOPT constants or equivalent integer values");
RETURN_FALSE;
}
if (_php_curl_setopt(ch, option, entry, return_value TSRMLS_CC)) {
+986 -905
View File
File diff suppressed because it is too large. Load diff
+1 -3
View File
@@ -2271,12 +2271,10 @@ PHP_FUNCTION(iconv_mime_decode_headers)
}
if (header_name != NULL) {
zval **elem;
zval **elem, *new_elem;
if (zend_hash_find(Z_ARRVAL_P(return_value), header_name, header_name_len, (void **)&elem) == SUCCESS) {
if (Z_TYPE_PP(elem) != IS_ARRAY) {
zval *new_elem;
MAKE_STD_ZVAL(new_elem);
array_init(new_elem);
+1 -1
View File
@@ -359,7 +359,7 @@ static void json_encode_r(smart_str *buf, zval *val TSRMLS_DC) /* {{{ */
double dbl = Z_DVAL_P(val);
if (!zend_isinf(dbl) && !zend_isnan(dbl)) {
len = spprintf(&d, 0, "%.*g", (int) EG(precision), dbl);
len = spprintf(&d, 0, "%.*k", (int) EG(precision), dbl);
smart_str_appendl(buf, d, len);
efree(d);
} else {
+26
View File
@@ -0,0 +1,26 @@
--TEST--
Bug #42785 (Incorrect formatting of double values with non-english locales)
--SKIPIF--
<?php
if (!extension_loaded("json")) {
print "skip";
} else if (!setlocale(LC_CTYPE, "de_DE", "de", "german", "ge", "de_DE.ISO8859-1", "ISO8859-1")) {
die("skip locale needed for this test is not supported on this platform");
}
?>
--FILE--
<?php
setlocale(LC_ALL, "de_DE", "de", "german", "ge", "de_DE.ISO8859-1", "ISO8859-1");
$foo = Array(100.10,"bar");
var_dump(json_encode($foo));
Class bar {}
$bar1 = new bar;
$bar1->a = 100.10;
$bar1->b = "foo";
var_dump(json_encode($bar1));
?>
--EXPECT--
string(13) "[100.1,"bar"]"
string(21) "{"a":100.1,"b":"foo"}"
+1 -1
View File
@@ -66,7 +66,7 @@
#include <mysql.h>
#include "php_ini.h"
#include "php_mysql.h"
#include "php_mysql_structs.h"
/* True globals, no need for thread safety */
static int le_result, le_link, le_plink;
-92
View File
@@ -22,105 +22,13 @@
#ifndef PHP_MYSQL_H
#define PHP_MYSQL_H
#ifdef PHP_WIN32
#define PHP_MYSQL_API __declspec(dllexport)
#else
#define PHP_MYSQL_API
#endif
#if HAVE_MYSQL
#ifdef ZTS
#include "TSRM.h"
#endif
extern zend_module_entry mysql_module_entry;
#define mysql_module_ptr &mysql_module_entry
PHP_MINIT_FUNCTION(mysql);
PHP_RINIT_FUNCTION(mysql);
PHP_MSHUTDOWN_FUNCTION(mysql);
PHP_RSHUTDOWN_FUNCTION(mysql);
PHP_MINFO_FUNCTION(mysql);
PHP_FUNCTION(mysql_connect);
PHP_FUNCTION(mysql_pconnect);
PHP_FUNCTION(mysql_close);
PHP_FUNCTION(mysql_select_db);
#if MYSQL_VERSION_ID < 40000
PHP_FUNCTION(mysql_create_db);
PHP_FUNCTION(mysql_drop_db);
#endif
PHP_FUNCTION(mysql_query);
PHP_FUNCTION(mysql_unbuffered_query);
PHP_FUNCTION(mysql_db_query);
PHP_FUNCTION(mysql_list_dbs);
PHP_FUNCTION(mysql_list_tables);
PHP_FUNCTION(mysql_list_fields);
PHP_FUNCTION(mysql_list_processes);
PHP_FUNCTION(mysql_error);
PHP_FUNCTION(mysql_errno);
PHP_FUNCTION(mysql_affected_rows);
PHP_FUNCTION(mysql_insert_id);
PHP_FUNCTION(mysql_result);
PHP_FUNCTION(mysql_num_rows);
PHP_FUNCTION(mysql_num_fields);
PHP_FUNCTION(mysql_fetch_row);
PHP_FUNCTION(mysql_fetch_array);
PHP_FUNCTION(mysql_fetch_assoc);
PHP_FUNCTION(mysql_fetch_object);
PHP_FUNCTION(mysql_data_seek);
PHP_FUNCTION(mysql_fetch_lengths);
PHP_FUNCTION(mysql_fetch_field);
PHP_FUNCTION(mysql_field_seek);
PHP_FUNCTION(mysql_free_result);
PHP_FUNCTION(mysql_field_name);
PHP_FUNCTION(mysql_field_table);
PHP_FUNCTION(mysql_field_len);
PHP_FUNCTION(mysql_field_type);
PHP_FUNCTION(mysql_field_flags);
PHP_FUNCTION(mysql_escape_string);
PHP_FUNCTION(mysql_real_escape_string);
PHP_FUNCTION(mysql_get_client_info);
PHP_FUNCTION(mysql_get_host_info);
PHP_FUNCTION(mysql_get_proto_info);
PHP_FUNCTION(mysql_get_server_info);
PHP_FUNCTION(mysql_info);
PHP_FUNCTION(mysql_stat);
PHP_FUNCTION(mysql_thread_id);
PHP_FUNCTION(mysql_client_encoding);
PHP_FUNCTION(mysql_ping);
#if (MYSQL_VERSION_ID >= 40113 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50007
PHP_FUNCTION(mysql_set_charset);
#endif
ZEND_BEGIN_MODULE_GLOBALS(mysql)
long default_link;
long num_links,num_persistent;
long max_links,max_persistent;
long allow_persistent;
long default_port;
char *default_host, *default_user, *default_password;
char *default_socket;
char *connect_error;
long connect_errno;
long connect_timeout;
long result_allocated;
long trace_mode;
ZEND_END_MODULE_GLOBALS(mysql)
#ifdef ZTS
# define MySG(v) TSRMG(mysql_globals_id, zend_mysql_globals *, v)
#else
# define MySG(v) (mysql_globals.v)
#endif
#else
#define mysql_module_ptr NULL
#endif
#define phpext_mysql_ptr mysql_module_ptr
+128
View File
@@ -0,0 +1,128 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_MYSQL_STRUCTS_H
#define PHP_MYSQL_STRUCTS_H
#ifdef PHP_WIN32
#define PHP_MYSQL_API __declspec(dllexport)
#else
#define PHP_MYSQL_API
#endif
#if HAVE_MYSQL
#ifdef ZTS
#include "TSRM.h"
#endif
extern zend_module_entry mysql_module_entry;
#define mysql_module_ptr &mysql_module_entry
PHP_MINIT_FUNCTION(mysql);
PHP_RINIT_FUNCTION(mysql);
PHP_MSHUTDOWN_FUNCTION(mysql);
PHP_RSHUTDOWN_FUNCTION(mysql);
PHP_MINFO_FUNCTION(mysql);
PHP_FUNCTION(mysql_connect);
PHP_FUNCTION(mysql_pconnect);
PHP_FUNCTION(mysql_close);
PHP_FUNCTION(mysql_select_db);
#if MYSQL_VERSION_ID < 40000
PHP_FUNCTION(mysql_create_db);
PHP_FUNCTION(mysql_drop_db);
#endif
PHP_FUNCTION(mysql_query);
PHP_FUNCTION(mysql_unbuffered_query);
PHP_FUNCTION(mysql_db_query);
PHP_FUNCTION(mysql_list_dbs);
PHP_FUNCTION(mysql_list_tables);
PHP_FUNCTION(mysql_list_fields);
PHP_FUNCTION(mysql_list_processes);
PHP_FUNCTION(mysql_error);
PHP_FUNCTION(mysql_errno);
PHP_FUNCTION(mysql_affected_rows);
PHP_FUNCTION(mysql_insert_id);
PHP_FUNCTION(mysql_result);
PHP_FUNCTION(mysql_num_rows);
PHP_FUNCTION(mysql_num_fields);
PHP_FUNCTION(mysql_fetch_row);
PHP_FUNCTION(mysql_fetch_array);
PHP_FUNCTION(mysql_fetch_assoc);
PHP_FUNCTION(mysql_fetch_object);
PHP_FUNCTION(mysql_data_seek);
PHP_FUNCTION(mysql_fetch_lengths);
PHP_FUNCTION(mysql_fetch_field);
PHP_FUNCTION(mysql_field_seek);
PHP_FUNCTION(mysql_free_result);
PHP_FUNCTION(mysql_field_name);
PHP_FUNCTION(mysql_field_table);
PHP_FUNCTION(mysql_field_len);
PHP_FUNCTION(mysql_field_type);
PHP_FUNCTION(mysql_field_flags);
PHP_FUNCTION(mysql_escape_string);
PHP_FUNCTION(mysql_real_escape_string);
PHP_FUNCTION(mysql_get_client_info);
PHP_FUNCTION(mysql_get_host_info);
PHP_FUNCTION(mysql_get_proto_info);
PHP_FUNCTION(mysql_get_server_info);
PHP_FUNCTION(mysql_info);
PHP_FUNCTION(mysql_stat);
PHP_FUNCTION(mysql_thread_id);
PHP_FUNCTION(mysql_client_encoding);
PHP_FUNCTION(mysql_ping);
#if (MYSQL_VERSION_ID >= 40113 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50007
PHP_FUNCTION(mysql_set_charset);
#endif
ZEND_BEGIN_MODULE_GLOBALS(mysql)
long default_link;
long num_links,num_persistent;
long max_links,max_persistent;
long allow_persistent;
long default_port;
char *default_host, *default_user, *default_password;
char *default_socket;
char *connect_error;
long connect_errno;
long connect_timeout;
long result_allocated;
long trace_mode;
ZEND_END_MODULE_GLOBALS(mysql)
#ifdef ZTS
# define MySG(v) TSRMG(mysql_globals_id, zend_mysql_globals *, v)
#else
# define MySG(v) (mysql_globals.v)
#endif
#else
#define mysql_module_ptr NULL
#endif
#define phpext_mysql_ptr mysql_module_ptr
#endif /* PHP_MYSQL_STRUCTS_H */
+2 -3
View File
@@ -125,8 +125,7 @@ void php_clear_stmt_bind(MY_STMT *stmt)
/* {{{ php_clear_mysql */
void php_clear_mysql(MY_MYSQL *mysql) {
if (mysql->li_read) {
efree(Z_STRVAL_P(mysql->li_read));
FREE_ZVAL(mysql->li_read);
zval_ptr_dtor(&(mysql->li_read));
mysql->li_read = NULL;
}
}
@@ -632,7 +631,7 @@ PHP_MINIT_FUNCTION(mysqli)
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_BIT", FIELD_TYPE_BIT, CONST_CS | CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("MYSQLI_SET_CHARSET_NAME", MYSQL_SET_CHARSET_NAME, CONST_CS | CONST_PERSISTENT);
/* replication */
REGISTER_LONG_CONSTANT("MYSQLI_RPL_MASTER", MYSQL_RPL_MASTER, CONST_CS | CONST_PERSISTENT);
+7 -5
View File
@@ -1170,8 +1170,7 @@ PHP_FUNCTION(mysqli_set_local_infile_default)
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
if (mysql->li_read) {
efree(Z_STRVAL_P(mysql->li_read));
zval_dtor(mysql->li_read);
zval_ptr_dtor(&(mysql->li_read));
mysql->li_read = NULL;
}
}
@@ -1199,11 +1198,14 @@ PHP_FUNCTION(mysqli_set_local_infile_handler)
efree(callback_name);
RETURN_FALSE;
}
efree(callback_name);
/* save callback function */
ALLOC_ZVAL(mysql->li_read);
ZVAL_STRING(mysql->li_read, callback_func->value.str.val, 1);
if (!mysql->li_read) {
MAKE_STD_ZVAL(mysql->li_read);
} else {
zval_dtor(mysql->li_read);
}
ZVAL_STRING(mysql->li_read, callback_name, 0);
RETURN_TRUE;
}
+2 -2
View File
@@ -86,8 +86,8 @@ static int __func(mysqli_object *obj, zval **retval TSRMLS_DC) \
ZVAL_LONG(*retval, l);\
} else { \
char *ret; \
int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (my_ulonglong)l); \
ZVAL_STRINGL(*retval, ret, l, 0); \
int ret_len = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (my_ulonglong)l); \
ZVAL_STRINGL(*retval, ret, ret_len, 0); \
} \
}\
return SUCCESS;\
+6 -3
View File
@@ -1260,7 +1260,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value,
}
/* }}} */
static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, int mode, int fetch_all TSRMLS_DC) /* {{{ */
static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, long mode, int fetch_all TSRMLS_DC) /* {{{ */
{
int flags = mode & PDO_FETCH_FLAGS;
@@ -1549,7 +1549,9 @@ static PHP_METHOD(PDOStatement, fetchAll)
if (!error) {
PDO_STMT_CLEAR_ERR();
MAKE_STD_ZVAL(data);
if ((how & PDO_FETCH_GROUP) || how == PDO_FETCH_KEY_PAIR) {
if ( (how & PDO_FETCH_GROUP) || how == PDO_FETCH_KEY_PAIR ||
(how == PDO_FETCH_USE_DEFAULT && stmt->default_fetch_type == PDO_FETCH_KEY_PAIR)
) {
array_init(return_value);
return_all = return_value;
} else {
@@ -1565,7 +1567,7 @@ static PHP_METHOD(PDOStatement, fetchAll)
do {
MAKE_STD_ZVAL(data);
} while (do_fetch(stmt, TRUE, data, how, PDO_FETCH_ORI_NEXT, 0, return_all TSRMLS_CC));
} else if (how == PDO_FETCH_KEY_PAIR) {
} else if (how == PDO_FETCH_KEY_PAIR || (how == PDO_FETCH_USE_DEFAULT && stmt->default_fetch_type == PDO_FETCH_KEY_PAIR)) {
while (do_fetch(stmt, TRUE, data, how, PDO_FETCH_ORI_NEXT, 0, return_all TSRMLS_CC));
} else {
array_init(return_value);
@@ -1916,6 +1918,7 @@ fail_out:
case PDO_FETCH_OBJ:
case PDO_FETCH_BOUND:
case PDO_FETCH_NAMED:
case PDO_FETCH_KEY_PAIR:
break;
case PDO_FETCH_COLUMN:
+40
View File
@@ -0,0 +1,40 @@
--TEST--
PDO Common: Bug #42917 (PDO::FETCH_KEY_PAIR doesn't work with setFetchMode)
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded('pdo')) die('skip');
$dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
require_once $dir . 'pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();
$db->exec("CREATE TABLE test (a varchar(100), b varchar(100), c varchar(100))");
for ($i = 0; $i < 5; $i++) {
$db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')");
}
$res = $db->query("SELECT a,b FROM test");
$res->setFetchMode(PDO::FETCH_KEY_PAIR);
var_dump($res->fetchAll());
?>
--EXPECT--
array(5) {
["test0"]=>
string(1) "0"
["test1"]=>
string(1) "1"
["test2"]=>
string(1) "2"
["test3"]=>
string(1) "3"
["test4"]=>
string(1) "4"
}
+9 -2
View File
@@ -5366,7 +5366,11 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var
assert(Z_TYPE_P(var_array) == IS_ARRAY);
if (zend_hash_num_elements(Z_ARRVAL_P(var_array)) == 0) {
return FAILURE;
smart_str_appends(&querystr, "INSERT INTO ");
smart_str_appends(&querystr, table);
smart_str_appends(&querystr, " DEFAULT VALUES");
goto no_values;
}
/* convert input array if needed */
@@ -5424,6 +5428,9 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var
/* Remove the trailing "," */
querystr.len--;
smart_str_appends(&querystr, ");");
no_values:
smart_str_0(&querystr);
if ((opt & (PGSQL_DML_EXEC|PGSQL_DML_ASYNC)) &&
@@ -5435,7 +5442,7 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var
}
cleanup:
if (!(opt & PGSQL_DML_NO_CONV)) {
if (!(opt & PGSQL_DML_NO_CONV) && converted) {
zval_dtor(converted);
FREE_ZVAL(converted);
}
+34
View File
@@ -0,0 +1,34 @@
--TEST--
Bug #42783 (pg_insert() does not support an empty value array)
--SKIPIF--
<?php
require_once('skipif.inc');
?>
--FILE--
<?php
require_once('config.inc');
$dbh = @pg_connect($conn_str);
if (!$dbh) {
die ("Could not connect to the server");
}
pg_query("CREATE TABLE php_test (id SERIAL PRIMARY KEY, time TIMESTAMP NOT NULL DEFAULT now())");
pg_insert($dbh, 'php_test', array());
var_dump(pg_fetch_assoc(pg_query("SELECT * FROM php_test")));
pg_query($dbh, "DROP TABLE php_test");
pg_close($dbh);
?>
===DONE===
--EXPECTF--
array(2) {
["id"]=>
string(%d) "%d"
["time"]=>
string(%d) "%s"
}
===DONE===
+3 -3
View File
@@ -1992,7 +1992,7 @@ ZEND_METHOD(reflection_parameter, getClass)
{
reflection_object *intern;
parameter_reference *param;
zend_class_entry **pce;
zend_class_entry **pce, *ce;
METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0);
GET_REFLECTION_OBJECT_PTR(param);
@@ -2011,7 +2011,7 @@ ZEND_METHOD(reflection_parameter, getClass)
* lint-mode.
*/
if (0 == strncmp(param->arg_info->class_name, "self", sizeof("self")- 1)) {
zend_class_entry *ce= param->fptr->common.scope;
ce = param->fptr->common.scope;
if (!ce) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Parameter uses 'self' as type hint but function is not a class member!");
@@ -2019,7 +2019,7 @@ ZEND_METHOD(reflection_parameter, getClass)
}
pce= &ce;
} else if (0 == strncmp(param->arg_info->class_name, "parent", sizeof("parent")- 1)) {
zend_class_entry *ce= param->fptr->common.scope;
ce = param->fptr->common.scope;
if (!ce) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Parameter uses 'parent' as type hint but function is not a class member!");
+4 -2
View File
@@ -1208,9 +1208,10 @@ static zval* get_zval_property(zval* object, char* name TSRMLS_DC)
zval *data;
zend_class_entry *old_scope;
INIT_PZVAL(&member);
ZVAL_STRING(&member, name, 0);
old_scope = EG(scope);
EG(scope) = Z_OBJCE_P(object);
EG(scope) = Z_OBJCE_P(object);
data = Z_OBJ_HT_P(object)->read_property(object, &member, BP_VAR_IS TSRMLS_CC);
if (data == EG(uninitialized_zval_ptr)) {
/* Hack for bug #32455 */
@@ -1241,9 +1242,10 @@ static void unset_zval_property(zval* object, char* name TSRMLS_DC)
zval member;
zend_class_entry *old_scope;
INIT_PZVAL(&member);
ZVAL_STRING(&member, name, 0);
old_scope = EG(scope);
EG(scope) = Z_OBJCE_P(object);
EG(scope) = Z_OBJCE_P(object);
Z_OBJ_HT_P(object)->unset_property(object, &member TSRMLS_CC);
EG(scope) = old_scope;
} else if (Z_TYPE_P(object) == IS_ARRAY) {
+1 -1
View File
@@ -918,7 +918,7 @@ try_again:
efree(http_body);
efree(loc);
if (new_url->scheme == NULL && new_url->path != NULL) {
new_url->scheme = NULL;
new_url->scheme = phpurl->scheme ? estrdup(phpurl->scheme) : NULL;
new_url->host = phpurl->host ? estrdup(phpurl->host) : NULL;
new_url->port = phpurl->port;
if (new_url->path && new_url->path[0] != '/') {
+66
View File
@@ -0,0 +1,66 @@
--TEST--
SOAP Classmap 4: encoding of objects with __get()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
ini_set("soap.wsdl_cache_enabled",0);
class A {
public $a;
function __construct($a){
$this->x = $a;
}
function __get($name) {
return @$this->a[$name];
}
function __set($name, $val) {
$this->a[$name] = $val;
}
function __unset($name) {
unset($this->a[$name]);
}
}
class B extends A {
function __construct($a){
parent::__construct($a);
$this->y = $a + 1;
}
}
function f(){
return new B(5);
}
class LocalSoapClient extends SoapClient {
function __construct($wsdl, $options) {
parent::__construct($wsdl, $options);
$this->server = new SoapServer($wsdl, $options);
$this->server->addFunction("f");
}
function __doRequest($request, $location, $action, $version) {
ob_start();
$this->server->handle($request);
$response = ob_get_contents();
ob_end_clean();
return $response;
}
}
$client = new LocalSoapClient(dirname(__FILE__)."/classmap003.wsdl",
array('classmap'=>array('A'=>'A','B'=>'B')));
print_r($client->f());
?>
--EXPECT--
B Object
(
[a] => Array
(
[x] => 5
[y] => 6
)
)
+5 -2
View File
@@ -1365,7 +1365,7 @@ SPL_METHOD(Array, hasChildren)
Create a sub iterator for the current element (same class as $this) */
SPL_METHOD(Array, getChildren)
{
zval *object = getThis(), **entry;
zval *object = getThis(), **entry, *flags;
spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
@@ -1387,7 +1387,10 @@ SPL_METHOD(Array, getChildren)
RETURN_ZVAL(*entry, 0, 0);
}
spl_instantiate_arg_ex1(Z_OBJCE_P(getThis()), &return_value, 0, *entry TSRMLS_CC);
MAKE_STD_ZVAL(flags);
ZVAL_LONG(flags, SPL_ARRAY_USE_OTHER);
spl_instantiate_arg_ex2(intern->std.ce, &return_value, 0, *entry, flags TSRMLS_CC);
zval_ptr_dtor(&flags);
}
/* }}} */
+5 -3
View File
@@ -1124,15 +1124,17 @@ static inline int spl_dual_it_fetch(spl_dual_it_object *intern, int check_more T
spl_dual_it_free(intern TSRMLS_CC);
if (!check_more || spl_dual_it_valid(intern TSRMLS_CC) == SUCCESS) {
intern->inner.iterator->funcs->get_current_data(intern->inner.iterator, &data TSRMLS_CC);
intern->current.data = *data;
intern->current.data->refcount++;
if (data && *data) {
intern->current.data = *data;
intern->current.data->refcount++;
}
if (intern->inner.iterator->funcs->get_current_key) {
intern->current.key_type = intern->inner.iterator->funcs->get_current_key(intern->inner.iterator, &intern->current.str_key, &intern->current.str_key_len, &intern->current.int_key TSRMLS_CC);
} else {
intern->current.key_type = HASH_KEY_IS_LONG;
intern->current.int_key = intern->current.pos;
}
return SUCCESS;
return EG(exception) ? FAILURE : SUCCESS;
}
return FAILURE;
}
+134
View File
@@ -0,0 +1,134 @@
--TEST--
Bug #42654 (RecursiveIteratorIterator modifies only part of leaves)
--FILE--
<?php
$data = array(1 => 'val1',
array(2 => 'val2',
array(3 => 'val3'),
),
4 => 'val4'
);
$iterator = new RecursiveIteratorIterator(new
RecursiveArrayIterator($data));
foreach($iterator as $foo) {
$key = $iterator->key();
echo "update $key\n";
var_dump($iterator->getInnerIterator());
$iterator->offsetSet($key, 'alter');
var_dump($iterator->getInnerIterator());
}
$copy = $iterator->getArrayCopy();
var_dump($copy);
?>
--EXPECTF--
update 1
object(RecursiveArrayIterator)#%d (3) {
[1]=>
string(4) "val1"
[2]=>
array(2) {
[2]=>
string(4) "val2"
[3]=>
array(1) {
[3]=>
string(4) "val3"
}
}
[4]=>
string(4) "val4"
}
object(RecursiveArrayIterator)#%d (3) {
[1]=>
string(5) "alter"
[2]=>
array(2) {
[2]=>
string(4) "val2"
[3]=>
array(1) {
[3]=>
string(4) "val3"
}
}
[4]=>
string(4) "val4"
}
update 2
object(RecursiveArrayIterator)#%d (2) {
[2]=>
string(4) "val2"
[3]=>
array(1) {
[3]=>
string(4) "val3"
}
}
object(RecursiveArrayIterator)#%d (2) {
[2]=>
string(5) "alter"
[3]=>
array(1) {
[3]=>
string(4) "val3"
}
}
update 3
object(RecursiveArrayIterator)#%d (1) {
[3]=>
string(4) "val3"
}
object(RecursiveArrayIterator)#%d (1) {
[3]=>
string(5) "alter"
}
update 4
object(RecursiveArrayIterator)#%d (3) {
[1]=>
string(5) "alter"
[2]=>
array(2) {
[2]=>
string(4) "val2"
[3]=>
array(1) {
[3]=>
string(4) "val3"
}
}
[4]=>
string(4) "val4"
}
object(RecursiveArrayIterator)#%d (3) {
[1]=>
string(5) "alter"
[2]=>
array(2) {
[2]=>
string(4) "val2"
[3]=>
array(1) {
[3]=>
string(4) "val3"
}
}
[4]=>
string(5) "alter"
}
array(3) {
[1]=>
string(5) "alter"
[2]=>
array(2) {
[2]=>
string(4) "val2"
[3]=>
array(1) {
[3]=>
string(4) "val3"
}
}
[4]=>
string(5) "alter"
}
+41
View File
@@ -0,0 +1,41 @@
--TEST--
Bug #42703 (Exception raised in an iterator::current() causes segfault in FilterIterator)
--FILE--
<?php
class BlaIterator implements Iterator
{
public function rewind() { }
public function next() { }
public function valid() {
return true;
}
public function current()
{
throw new Exception('boo');
}
public function key() { }
}
$it = new BlaIterator();
$itit = new IteratorIterator($it);
try {
foreach($itit as $key => $value) {
echo $key, $value;
}
}
catch (Exception $e) {
var_dump($e->getMessage());
}
var_dump($itit->current());
var_dump($itit->key());
?>
--EXPECTF--
string(3) "boo"
NULL
NULL
+6 -4
View File
@@ -618,7 +618,7 @@ static int array_user_compare(const void *a, const void *b TSRMLS_DC) /* {{{ */
/* check if comparison function is valid */
#define PHP_ARRAY_CMP_FUNC_CHECK(func_name) \
if (!zend_is_callable(*func_name, 0, NULL)) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid comparison function."); \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid comparison function"); \
BG(user_compare_fci_cache) = old_user_compare_fci_cache; \
BG(user_compare_func_name) = old_compare_func; \
RETURN_FALSE; \
@@ -1079,11 +1079,13 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive
SEPARATE_ZVAL_TO_MAKE_IS_REF(args[0]);
thash = HASH_OF(*(args[0]));
if (thash == target_hash) {
if (thash->nApplyCount > 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
return 0;
}
thash->nApplyCount++;
php_array_walk(thash, userdata, recursive TSRMLS_CC);
thash->nApplyCount--;
} else {
zend_fcall_info fci;
@@ -1842,7 +1844,7 @@ PHP_FUNCTION(shuffle)
{
zval *array;
if (zend_parse_parameters(1 TSRMLS_CC, "a", &array) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
@@ -3157,7 +3159,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
BG(user_compare_func_name) = args[arr_argc + 1];/* data - key */
} else {
efree(args);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_compare_type is %d. key_compare_type is %d. This should never happen. Please report as a bug.", data_compare_type, key_compare_type);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_compare_type is %d. key_compare_type is %d. This should never happen. Please report as a bug", data_compare_type, key_compare_type);
return;
}
} else {
+3 -3
View File
@@ -4496,7 +4496,7 @@ PHP_FUNCTION(putenv)
}
}
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter syntax.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter syntax");
RETURN_FALSE;
}
/* }}} */
@@ -4810,7 +4810,7 @@ PHP_FUNCTION(time_sleep_until)
c_ts = (double)(d_ts - tm.tv_sec - tm.tv_usec / 1000000.00);
if (c_ts < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sleep until to time is less than current time.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sleep until to time is less than current time");
RETURN_FALSE;
}
@@ -6273,7 +6273,7 @@ static int copy_request_variable(void *pDest, int num_args, va_list args, zend_h
prefix_len = va_arg(args, uint);
if (!prefix_len && !hash_key->nKeyLength) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Numeric key detected - possible security hazard.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Numeric key detected - possible security hazard");
return 0;
}
+1 -1
View File
@@ -290,7 +290,7 @@ PHP_FUNCTION(get_browser)
char *browscap = INI_STR("browscap");
if (!browscap || !browscap[0]) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "browscap ini directive not set.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "browscap ini directive not set");
RETURN_FALSE;
}
+1 -1
View File
@@ -463,7 +463,7 @@ PHP_FUNCTION(proc_nice)
errno = 0;
nice(pri);
if (errno) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only a super user may attempt to increase the priority of a process.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only a super user may attempt to increase the priority of a process");
RETURN_FALSE;
}
+1 -1
View File
@@ -1880,7 +1880,7 @@ static php_stream_filter *consumed_filter_create(const char *filtername, zval *f
/* Create this filter */
data = pecalloc(1, sizeof(php_consumed_filter_data), persistent);
if (!data) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes.", sizeof(php_consumed_filter_data));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", sizeof(php_consumed_filter_data));
return NULL;
}
data->persistent = persistent;
+3 -3
View File
@@ -445,7 +445,7 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
if (argnum <= 0) {
efree(result);
efree(args);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument number must be greater than zero.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument number must be greater than zero");
return NULL;
}
@@ -487,7 +487,7 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
if ((width = php_sprintf_getnumber(format, &inpos)) < 0) {
efree(result);
efree(args);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Width must be greater than zero and less than %d.", INT_MAX);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Width must be greater than zero and less than %d", INT_MAX);
return NULL;
}
adjusting |= ADJ_WIDTH;
@@ -504,7 +504,7 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
if ((precision = php_sprintf_getnumber(format, &inpos)) < 0) {
efree(result);
efree(args);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Precision must be greater than zero and less than %d.", INT_MAX);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Precision must be greater than zero and less than %d", INT_MAX);
return NULL;
}
adjusting |= ADJ_PRECISION;
+24 -22
View File
@@ -69,7 +69,11 @@
#include "php_fopen_wrappers.h"
#define FTPS_ENCRYPT_DATA 1
#define GET_FTP_RESULT(stream) get_ftp_result((stream), tmp_line, sizeof(tmp_line) TSRMLS_CC)
/* {{{ get_ftp_result
*/
static inline int get_ftp_result(php_stream *stream, char *buffer, size_t buffer_size TSRMLS_DC)
{
while (php_stream_gets(stream, buffer, buffer_size-1) &&
@@ -77,24 +81,21 @@ static inline int get_ftp_result(php_stream *stream, char *buffer, size_t buffer
isdigit((int) buffer[2]) && buffer[3] == ' '));
return strtol(buffer, NULL, 10);
}
#define GET_FTP_RESULT(stream) get_ftp_result((stream), tmp_line, sizeof(tmp_line) TSRMLS_CC)
/* }}} */
#define FTPS_ENCRYPT_DATA 1
static int php_stream_ftp_stream_stat(php_stream_wrapper *wrapper,
php_stream *stream,
php_stream_statbuf *ssb
TSRMLS_DC)
/* {{{ php_stream_ftp_stream_stat
*/
static int php_stream_ftp_stream_stat(php_stream_wrapper *wrapper, php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)
{
/* For now, we return with a failure code to prevent the underlying
* file's details from being used instead. */
return -1;
}
/* }}} */
static int php_stream_ftp_stream_close(php_stream_wrapper *wrapper,
php_stream *stream
TSRMLS_DC)
/* {{{ php_stream_ftp_stream_close
*/
static int php_stream_ftp_stream_close(php_stream_wrapper *wrapper, php_stream *stream TSRMLS_DC)
{
php_stream *controlstream = (php_stream *)stream->wrapperdata;
@@ -105,6 +106,7 @@ static int php_stream_ftp_stream_close(php_stream_wrapper *wrapper,
}
return 0;
}
/* }}} */
/* {{{ php_ftp_fopen_connect
*/
@@ -410,7 +412,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
}
if (strpbrk(mode, "wa+")) {
if (read_write) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "FTP does not support simultaneous read/write connections.");
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "FTP does not support simultaneous read/write connections");
return NULL;
}
if (strchr(mode, 'a')) {
@@ -421,7 +423,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
}
if (!read_write) {
/* No mode specified? */
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unknown file open mode.");
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unknown file open mode");
return NULL;
}
@@ -484,7 +486,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
goto errexit;
}
} else {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Remote file already exists and overwrite context option not specified.");
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Remote file already exists and overwrite context option not specified");
errno = EEXIST;
goto errexit;
}
@@ -564,7 +566,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
php_url_free(resource);
return datastream;
errexit:
errexit:
if (resource) {
php_url_free(resource);
}
@@ -728,7 +730,7 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, char *path, cha
php_url_free(resource);
return php_stream_alloc(&php_ftp_dirstream_ops, datastream, 0, mode);
opendir_errexit:
opendir_errexit:
if (resource) {
php_url_free(resource);
}
@@ -828,7 +830,7 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, char *url, int f
#endif
} else {
/* error or unsupported command */
mdtm_error:
mdtm_error:
#ifdef NETWARE
ssb->sb.st_mtime.tv_sec = -1;
#else
@@ -860,7 +862,7 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, char *url, int f
php_url_free(resource);
return 0;
stat_errexit:
stat_errexit:
if (resource) {
php_url_free(resource);
}
@@ -910,7 +912,7 @@ static int php_stream_ftp_unlink(php_stream_wrapper *wrapper, char *url, int opt
php_stream_close(stream);
return 1;
unlink_errexit:
unlink_errexit:
if (resource) {
php_url_free(resource);
}
@@ -986,7 +988,7 @@ static int php_stream_ftp_rename(php_stream_wrapper *wrapper, char *url_from, ch
php_stream_close(stream);
return 1;
rename_errexit:
rename_errexit:
if (resource_from) {
php_url_free(resource_from);
}
@@ -1083,7 +1085,7 @@ static int php_stream_ftp_mkdir(php_stream_wrapper *wrapper, char *url, int mode
return 1;
mkdir_errexit:
mkdir_errexit:
if (resource) {
php_url_free(resource);
}
@@ -1133,7 +1135,7 @@ static int php_stream_ftp_rmdir(php_stream_wrapper *wrapper, char *url, int opti
return 1;
rmdir_errexit:
rmdir_errexit:
if (resource) {
php_url_free(resource);
}
+46 -9
View File
@@ -484,18 +484,29 @@ struct basic_entities_dec {
} \
mbseq[mbpos++] = (mbchar); }
#define CHECK_LEN(pos, chars_need) \
if((str_len - (pos)) < chars_need) { \
*status = FAILURE; \
return 0; \
}
/* {{{ get_next_char
*/
inline static unsigned short get_next_char(enum entity_charset charset,
unsigned char * str,
int str_len,
int * newpos,
unsigned char * mbseq,
int * mbseqlen)
int * mbseqlen,
int *status)
{
int pos = *newpos;
int mbpos = 0;
int mbspace = *mbseqlen;
unsigned short this_char = str[pos++];
unsigned char next_char;
*status = SUCCESS;
if (mbspace <= 0) {
*mbseqlen = 0;
@@ -517,6 +528,10 @@ inline static unsigned short get_next_char(enum entity_charset charset,
do {
if (this_char < 0x80) {
more = 0;
if(stat) {
/* we didn't finish the UTF sequence correctly */
*status = FAILURE;
}
break;
} else if (this_char < 0xc0) {
switch (stat) {
@@ -555,6 +570,7 @@ inline static unsigned short get_next_char(enum entity_charset charset,
break;
default:
/* invalid */
*status = FAILURE;
more = 0;
}
}
@@ -562,21 +578,27 @@ inline static unsigned short get_next_char(enum entity_charset charset,
else if (this_char < 0xe0) {
stat = 0x10; /* 2 byte */
utf = (this_char & 0x1f) << 6;
CHECK_LEN(pos, 1);
} else if (this_char < 0xf0) {
stat = 0x20; /* 3 byte */
utf = (this_char & 0xf) << 12;
CHECK_LEN(pos, 2);
} else if (this_char < 0xf8) {
stat = 0x30; /* 4 byte */
utf = (this_char & 0x7) << 18;
CHECK_LEN(pos, 3);
} else if (this_char < 0xfc) {
stat = 0x40; /* 5 byte */
utf = (this_char & 0x3) << 24;
CHECK_LEN(pos, 4);
} else if (this_char < 0xfe) {
stat = 0x50; /* 6 byte */
utf = (this_char & 0x1) << 30;
CHECK_LEN(pos, 5);
} else {
/* invalid; bail */
more = 0;
*status = FAILURE;
break;
}
@@ -594,7 +616,8 @@ inline static unsigned short get_next_char(enum entity_charset charset,
/* check if this is the first of a 2-byte sequence */
if (this_char >= 0xa1 && this_char <= 0xfe) {
/* peek at the next char */
unsigned char next_char = str[pos];
CHECK_LEN(pos, 1);
next_char = str[pos];
if ((next_char >= 0x40 && next_char <= 0x7e) ||
(next_char >= 0xa1 && next_char <= 0xfe)) {
/* yes, this a wide char */
@@ -614,7 +637,8 @@ inline static unsigned short get_next_char(enum entity_charset charset,
(this_char >= 0xe0 && this_char <= 0xef)
) {
/* peek at the next char */
unsigned char next_char = str[pos];
CHECK_LEN(pos, 1);
next_char = str[pos];
if ((next_char >= 0x40 && next_char <= 0x7e) ||
(next_char >= 0x80 && next_char <= 0xfc))
{
@@ -633,7 +657,8 @@ inline static unsigned short get_next_char(enum entity_charset charset,
/* check if this is the first of a multi-byte sequence */
if (this_char >= 0xa1 && this_char <= 0xfe) {
/* peek at the next char */
unsigned char next_char = str[pos];
CHECK_LEN(pos, 1);
next_char = str[pos];
if (next_char >= 0xa1 && next_char <= 0xfe) {
/* yes, this a jis kanji char */
this_char <<= 8;
@@ -644,7 +669,8 @@ inline static unsigned short get_next_char(enum entity_charset charset,
} else if (this_char == 0x8e) {
/* peek at the next char */
unsigned char next_char = str[pos];
CHECK_LEN(pos, 1);
next_char = str[pos];
if (next_char >= 0xa1 && next_char <= 0xdf) {
/* JIS X 0201 kana */
this_char <<= 8;
@@ -655,8 +681,10 @@ inline static unsigned short get_next_char(enum entity_charset charset,
} else if (this_char == 0x8f) {
/* peek at the next two char */
unsigned char next_char = str[pos];
unsigned char next2_char = str[pos+1];
unsigned char next2_char;
CHECK_LEN(pos, 2);
next_char = str[pos];
next2_char = str[pos+1];
if ((next_char >= 0xa1 && next_char <= 0xfe) &&
(next2_char >= 0xa1 && next2_char <= 0xfe)) {
/* JIS X 0212 hojo-kanji */
@@ -1098,13 +1126,22 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, int oldlen, int *ne
maxlen = 128;
replaced = emalloc (maxlen);
len = 0;
i = 0;
while (i < oldlen) {
unsigned char mbsequence[16]; /* allow up to 15 characters in a multibyte sequence */
int mbseqlen = sizeof(mbsequence);
unsigned short this_char = get_next_char(charset, old, &i, mbsequence, &mbseqlen);
int status = SUCCESS;
unsigned short this_char = get_next_char(charset, old, oldlen, &i, mbsequence, &mbseqlen, &status);
if(status == FAILURE) {
/* invalid MB sequence */
efree(replaced);
if(!PG(display_errors)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid multibyte sequence in argument");
}
*newlen = 0;
return STR_EMPTY_ALLOC();
}
matches_map = 0;
if (len + 16 > maxlen)
+2 -2
View File
@@ -76,7 +76,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
}
if (zend_hash_get_current_data_ex(ht, (void **)&zdata, NULL) == FAILURE || !zdata || !(*zdata)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error traversing form data array.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error traversing form data array");
return FAILURE;
}
if (Z_TYPE_PP(zdata) == IS_ARRAY || Z_TYPE_PP(zdata) == IS_OBJECT) {
@@ -203,7 +203,7 @@ PHP_FUNCTION(http_build_query)
}
if (Z_TYPE_P(formdata) != IS_ARRAY && Z_TYPE_P(formdata) != IS_OBJECT) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parameter 1 expected to be Array or Object. Incorrect value given.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parameter 1 expected to be Array or Object. Incorrect value given");
RETURN_FALSE;
}
+1 -1
View File
@@ -137,7 +137,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
/* Normal http request (possibly with proxy) */
if (strpbrk(mode, "awx+")) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP wrapper does not support writeable connections.");
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP wrapper does not support writeable connections");
php_url_free(resource);
return NULL;
}
+1 -2
View File
@@ -1317,8 +1317,7 @@ PHP_FUNCTION(getimagesize)
#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
result = php_handle_swc(stream TSRMLS_CC);
#else
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "The image is a compressed SWF file, but you do not have a static version of the zlib extension enabled.");
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "The image is a compressed SWF file, but you do not have a static version of the zlib extension enabled");
#endif
break;
case IMAGE_FILETYPE_PSD:
+1 -1
View File
@@ -98,7 +98,7 @@ PHP_FUNCTION(mail)
char *p, *e;
if (PG(safe_mode) && (ZEND_NUM_ARGS() == 5)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE");
RETURN_FALSE;
}
+1 -1
View File
@@ -253,7 +253,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch
pathdup = estrndup(path + 6, strlen(path + 6));
p = strstr(pathdup, "/resource=");
if (!p) {
php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "No URL resource specified.");
php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "No URL resource specified");
efree(pathdup);
return NULL;
}
+9 -9
View File
@@ -357,7 +357,7 @@ PHP_FUNCTION(stream_socket_recvfrom)
}
if (to_read <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0");
RETURN_FALSE;
}
@@ -406,7 +406,7 @@ PHP_FUNCTION(stream_get_contents)
php_stream_from_zval(stream, &zsrc);
if (pos > 0 && php_stream_seek(stream, pos, SEEK_SET) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream.", pos);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
RETURN_FALSE;
}
@@ -442,7 +442,7 @@ PHP_FUNCTION(stream_copy_to_stream)
php_stream_from_zval(dest, &zdest);
if (pos > 0 && php_stream_seek(src, pos, SEEK_SET) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream.", pos);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
RETURN_FALSE;
}
@@ -757,10 +757,10 @@ PHP_FUNCTION(stream_select)
convert_to_long_ex(sec);
if (Z_LVAL_PP(sec) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The seconds parameter must be greater than 0.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The seconds parameter must be greater than 0");
RETURN_FALSE;
} else if (usec < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The microseconds parameter must be greater than 0.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The microseconds parameter must be greater than 0");
RETURN_FALSE;
}
@@ -945,7 +945,7 @@ PHP_FUNCTION(stream_context_get_options)
}
context = decode_context_param(zcontext TSRMLS_CC);
if (!context) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter");
RETURN_FALSE;
}
@@ -975,7 +975,7 @@ PHP_FUNCTION(stream_context_set_option)
/* figure out where the context is coming from exactly */
context = decode_context_param(zcontext TSRMLS_CC);
if (!context) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter");
RETURN_FALSE;
}
@@ -1002,7 +1002,7 @@ PHP_FUNCTION(stream_context_set_params)
context = decode_context_param(zcontext TSRMLS_CC);
if (!context) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter");
RETURN_FALSE;
}
@@ -1186,7 +1186,7 @@ PHP_FUNCTION(stream_get_line)
}
if (max_length < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The maximum allowed length must be greater than or equal to zero.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The maximum allowed length must be greater than or equal to zero");
RETURN_FALSE;
}
if (!max_length) {
+32 -34
View File
@@ -511,22 +511,22 @@ static inline int php_charmask(unsigned char *input, int len, char *mask TSRMLS_
/* Error, try to be as helpful as possible:
(a range ending/starting with '.' won't be captured here) */
if (end-len >= input) { /* there was no 'left' char */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, no character to the left of '..'.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, no character to the left of '..'");
result = FAILURE;
continue;
}
if (input+2 >= end) { /* there is no 'right' char */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, no character to the right of '..'.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, no character to the right of '..'");
result = FAILURE;
continue;
}
if (input[-1] > input[2]) { /* wrong order */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, '..'-range needs to be incrementing.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range, '..'-range needs to be incrementing");
result = FAILURE;
continue;
}
/* FIXME: better error (a..b..c is the only left possibility?) */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '..'-range");
result = FAILURE;
continue;
} else {
@@ -861,7 +861,7 @@ PHP_FUNCTION(explode)
}
if (! Z_STRLEN_PP(delim)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter");
RETURN_FALSE;
}
@@ -988,7 +988,7 @@ PHP_FUNCTION(implode)
if (argc == 1) {
if (Z_TYPE_PP(arg1) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument to implode must be an array.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument must be an array");
return;
}
@@ -1008,7 +1008,7 @@ PHP_FUNCTION(implode)
convert_to_string_ex(arg1);
delim = *arg1;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad arguments.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments passed");
return;
}
}
@@ -1544,7 +1544,7 @@ PHP_FUNCTION(stristr)
if (Z_TYPE_PP(needle) == IS_STRING) {
if (!Z_STRLEN_PP(needle)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter");
efree(haystack_orig);
RETURN_FALSE;
}
@@ -1592,7 +1592,7 @@ PHP_FUNCTION(strstr)
if (Z_TYPE_PP(needle) == IS_STRING) {
if (!Z_STRLEN_PP(needle)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter");
RETURN_FALSE;
}
@@ -1645,13 +1645,13 @@ PHP_FUNCTION(strpos)
}
if (offset < 0 || offset > Z_STRLEN_PP(haystack)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string");
RETURN_FALSE;
}
if (Z_TYPE_PP(needle) == IS_STRING) {
if (!Z_STRLEN_PP(needle)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter");
RETURN_FALSE;
}
@@ -1695,7 +1695,7 @@ PHP_FUNCTION(stripos)
}
if (offset < 0 || offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string");
RETURN_FALSE;
}
@@ -1725,7 +1725,7 @@ PHP_FUNCTION(stripos)
needle_char[0] = tolower((char) Z_DVAL_P(needle));
break;
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "needle is not a string or an integer.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "needle is not a string or an integer");
efree(haystack_dup);
RETURN_FALSE;
break;
@@ -2038,7 +2038,7 @@ PHP_FUNCTION(chunk_split)
}
if (chunklen <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Chunk length should be greater than zero.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Chunk length should be greater than zero");
RETURN_FALSE;
}
@@ -2181,8 +2181,7 @@ PHP_FUNCTION(substr_replace)
if (Z_TYPE_PP(str) == IS_STRING) {
if (
(argc == 3 && Z_TYPE_PP(from) == IS_ARRAY)
||
(argc == 3 && Z_TYPE_PP(from) == IS_ARRAY) ||
(argc == 4 && Z_TYPE_PP(from) != Z_TYPE_PP(len))
) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'from' and 'len' should be of same type - numerical or array ");
@@ -2195,7 +2194,6 @@ PHP_FUNCTION(substr_replace)
}
}
}
if (Z_TYPE_PP(str) != IS_ARRAY) {
if (Z_TYPE_PP(from) != IS_ARRAY) {
@@ -2253,7 +2251,7 @@ PHP_FUNCTION(substr_replace)
result[result_len] = '\0';
RETURN_STRINGL(result, result_len, 0);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Functionality of 'from' and 'len' as arrays is not implemented.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Functionality of 'from' and 'len' as arrays is not implemented");
RETURN_STRINGL(Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1);
}
} else { /* str is array of strings */
@@ -2646,7 +2644,7 @@ PHP_FUNCTION(strtr)
}
if (ac == 2 && Z_TYPE_PP(from) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The second argument is not an array.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The second argument is not an array");
RETURN_FALSE;
}
@@ -3951,7 +3949,7 @@ PHP_FUNCTION(setlocale)
cat = Z_LVAL_PP(pcategory);
} else { /* FIXME: The following behaviour should be removed. */
char *category;
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passing locale category name as string is deprecated. Use the LC_* -constants instead.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passing locale category name as string is deprecated. Use the LC_* -constants instead");
convert_to_string_ex(pcategory);
category = Z_STRVAL_P(*pcategory);
@@ -3972,7 +3970,7 @@ PHP_FUNCTION(setlocale)
else if (!strcasecmp ("LC_TIME", category))
cat = LC_TIME;
else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid locale category name %s, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, or LC_TIME.", category);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid locale category name %s, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, or LC_TIME", category);
efree(args);
RETURN_FALSE;
}
@@ -4411,7 +4409,7 @@ PHP_FUNCTION(str_repeat)
convert_to_long_ex(mult);
if (Z_LVAL_PP(mult) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Second argument has to be greater than or equal to 0.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Second argument has to be greater than or equal to 0");
return;
}
@@ -4475,7 +4473,7 @@ PHP_FUNCTION(count_chars)
mymode = Z_LVAL_PP(mode);
if (mymode < 0 || mymode > 4) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown mode.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown mode");
RETURN_FALSE;
}
}
@@ -4666,7 +4664,7 @@ PHP_FUNCTION(substr_count)
convert_to_string_ex(needle);
if (Z_STRLEN_PP(needle) == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty substring.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty substring");
RETURN_FALSE;
}
@@ -4676,12 +4674,12 @@ PHP_FUNCTION(substr_count)
if (ac > 2) {
convert_to_long_ex(offset);
if (Z_LVAL_PP(offset) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset should be greater than or equal to 0.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset should be greater than or equal to 0");
RETURN_FALSE;
}
if (Z_LVAL_PP(offset) > Z_STRLEN_PP(haystack)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value %ld exceeds string length.", Z_LVAL_PP(offset));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value %ld exceeds string length", Z_LVAL_PP(offset));
RETURN_FALSE;
}
p += Z_LVAL_PP(offset);
@@ -4689,11 +4687,11 @@ PHP_FUNCTION(substr_count)
if (ac == 4) {
convert_to_long_ex(length);
if (Z_LVAL_PP(length) <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length should be greater than 0.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length should be greater than 0");
RETURN_FALSE;
}
if (Z_LVAL_PP(length) > (Z_STRLEN_PP(haystack) - Z_LVAL_PP(offset))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value %ld exceeds string length.", Z_LVAL_PP(length));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value %ld exceeds string length", Z_LVAL_PP(length));
RETURN_FALSE;
}
endp = p + Z_LVAL_PP(length);
@@ -4759,7 +4757,7 @@ PHP_FUNCTION(str_pad)
if (ZEND_NUM_ARGS() > 2) {
convert_to_string_ex(pad_string);
if (Z_STRLEN_PP(pad_string) == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding string cannot be empty.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding string cannot be empty");
return;
}
pad_str_val = Z_STRVAL_PP(pad_string);
@@ -4769,7 +4767,7 @@ PHP_FUNCTION(str_pad)
convert_to_long_ex(pad_type);
pad_type_val = Z_LVAL_PP(pad_type);
if (pad_type_val < STR_PAD_LEFT || pad_type_val > STR_PAD_BOTH) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH");
return;
}
}
@@ -5053,7 +5051,7 @@ PHP_FUNCTION(str_split)
}
if (split_length <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length of each segment must be greater than zero.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length of each segment must be greater than zero");
RETURN_FALSE;
}
@@ -5091,7 +5089,7 @@ PHP_FUNCTION(strpbrk)
}
if (!char_list_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The character list cannot be empty.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The character list cannot be empty");
RETURN_FALSE;
}
@@ -5127,12 +5125,12 @@ PHP_FUNCTION(substr_compare)
offset = (offset < 0) ? 0 : offset;
}
if(offset > s1_len) {
if (offset > s1_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed initial string length");
RETURN_FALSE;
}
if(len > s1_len - offset) {
if (len > s1_len - offset) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length cannot exceed initial string length");
RETURN_FALSE;
}
@@ -0,0 +1,71 @@
--TEST--
Test array_flip() function : basic functionality
--FILE--
<?php
/* Prototype : array array_flip(array $input)
* Description: Return array with key <-> value flipped
* Source code: ext/standard/array.c
*/
echo "*** Testing array_flip() : basic functionality ***\n";
// array with default keys - numeric values
$input = array(1, 2);
var_dump( array_flip($input) );
// array with default keys - string values
$input = array('value1', "value2");
var_dump( array_flip($input) );
// associative arrays - key as string
$input = array('key1' => 1, "key2" => 2);
var_dump( array_flip($input) );
// associative arrays - key as numeric
$input = array(1 => 'one', 2 => "two");
var_dump( array_flip($input) );
// combination of associative and non-associative array
$input = array(1 => 'one','two', 3 => 'three', 4, "five" => 5);
var_dump( array_flip($input) );
echo "Done"
?>
--EXPECTF--
*** Testing array_flip() : basic functionality ***
array(2) {
[1]=>
int(0)
[2]=>
int(1)
}
array(2) {
["value1"]=>
int(0)
["value2"]=>
int(1)
}
array(2) {
[1]=>
string(4) "key1"
[2]=>
string(4) "key2"
}
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
array(5) {
["one"]=>
int(1)
["two"]=>
int(2)
["three"]=>
int(3)
[4]=>
int(4)
[5]=>
string(4) "five"
}
Done
@@ -0,0 +1,34 @@
--TEST--
Test array_flip() function : error conditions
--FILE--
<?php
/* Prototype : array array_flip(array $input)
* Description: Return array with key <-> value flipped
* Source code: ext/standard/array.c
*/
echo "*** Testing array_flip() : error conditions ***\n";
// Zero arguments
echo "-- Testing array_flip() function with Zero arguments --\n";
var_dump( array_flip() );
//one more than the expected number of arguments
echo "-- Testing array_flip() function with more than expected no. of arguments --\n";
$input = array(1 => 'one', 2 => 'two');
$extra_arg = 10;
var_dump( array_flip($input, $extra_arg) );
echo "Done"
?>
--EXPECTF--
*** Testing array_flip() : error conditions ***
-- Testing array_flip() function with Zero arguments --
Warning: Wrong parameter count for array_flip() in %s on line %d
NULL
-- Testing array_flip() function with more than expected no. of arguments --
Warning: Wrong parameter count for array_flip() in %s on line %d
NULL
Done
@@ -0,0 +1,178 @@
--TEST--
Test array_flip() function : usage variations - unexpected values for 'input' argument
--FILE--
<?php
/* Prototype : array array_flip(array $input)
* Description: Return array with key <-> value flipped
* Source code: ext/standard/array.c
*/
echo "*** Testing array_flip() : usage variations - unexpected values for 'input' ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//class definition for object variable
class MyClass
{
public function __toString()
{
return 'object';
}
}
//resource variable
$fp = fopen(__FILE__,'r');
//array of values for 'input' argument
$values = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
10.5e10,
10.6E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
/*15*/ FALSE,
// empty data
"",
'',
// string data
"string",
'string',
// object data
/*20*/ new MyClass(),
// undefined data
@$undefined_var,
// unset data
@$unset_var,
//resource data
/*23*/ $fp
);
// loop through each element of $values for 'input' argument
for($count = 0; $count < count($values); $count++) {
echo "-- Iteration ".($count + 1). " --\n";
var_dump( array_flip($values[$count]) );
};
//closing resource
fclose($fp);
echo "Done"
?>
--EXPECTF--
*** Testing array_flip() : usage variations - unexpected values for 'input' ***
-- Iteration 1 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 2 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 3 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 4 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 5 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 6 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 7 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 8 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 9 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 10 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 11 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 12 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 13 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 14 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 15 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 16 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 17 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 18 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 19 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 20 --
array(0) {
}
-- Iteration 21 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 22 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
-- Iteration 23 --
Warning: array_flip(): The argument should be an array in %s on line %d
bool(false)
Done
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,90 @@
--TEST--
Test array_flip() function : usage variations - 'input' argument with different invalid values for keys
--FILE--
<?php
/* Prototype : array array_flip(array $input)
* Description: Return array with key <-> value flipped
* Source code: ext/standard/array.c
*/
/*
* Trying different invalid values for 'input' array argument
*/
echo "*** Testing array_flip() : different invalid values in 'input' array argument ***\n";
// class definition for object data
class MyClass
{
public function __toString()
{
return 'object';
}
}
$obj = new MyClass();
// resource data
$fp = fopen(__FILE__, 'r');
$input = array(
// float values
'float_value1' => 1.2,
'float_value2' => 0.5,
'float_value3' => 3.4E3,
'float_value4' => 5.6E-6,
// bool values
'bool_value1' => true,
'bool_value2' => false,
'bool_value3' => TRUE,
'bool_value4' => FALSE,
// null values
'null_value1' => null,
// array value
'array_value' => array(1),
// object value
'obj_value' => $obj,
// resource value
'resource_value' => $fp,
);
var_dump( array_flip($input) );
// closing resource
fclose($fp);
echo "Done"
?>
--EXPECTF--
*** Testing array_flip() : different invalid values in 'input' array argument ***
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
array(0) {
}
Done
@@ -0,0 +1,82 @@
--TEST--
Test array_flip() function : usage variations - 'input' argument with repeatitive keys and values
--FILE--
<?php
/* Prototype : array array_flip(array $input)
* Description: Return array with key <-> value flipped
* Source code: ext/standard/array.c
*/
/*
* Using different types of repeatitive keys as well as values for 'input' array
*/
echo "*** Testing array_flip() : 'input' array with repeatitive keys/values ***\n";
// array with numeric key repeatition
$input = array(1 => 'value', 2 => 'VALUE', 1 => "VaLuE", 3.4 => 4, 3.4 => 5);
var_dump( array_flip($input) );
// array with string key repeatition
$input = array("key" => 1, "two" => 'TWO', 'three' => 3, 'key' => "FOUR");
var_dump( array_flip($input) );
// array with bool key repeatition
$input = array(true => 1, false => 0, TRUE => -1);
var_dump( array_flip($input) );
// array with null key repeatition
$input = array(null => "Hello", NULL => 0);
var_dump( array_flip($input) );
// array with numeric value repeatition
$input = array('one' => 1, 'two' => 2, 3 => 1, "index" => 1);
var_dump( array_flip($input) );
//array with string value repeatition
$input = array('key1' => "value1", "key2" => '2', 'key3' => 'value1');
var_dump( array_flip($input) );
echo "Done"
?>
--EXPECTF--
*** Testing array_flip() : 'input' array with repeatitive keys/values ***
array(3) {
["VaLuE"]=>
int(1)
["VALUE"]=>
int(2)
[5]=>
int(3)
}
array(3) {
["FOUR"]=>
string(3) "key"
["TWO"]=>
string(3) "two"
[3]=>
string(5) "three"
}
array(2) {
[-1]=>
int(1)
[0]=>
int(0)
}
array(1) {
[0]=>
string(0) ""
}
array(2) {
[1]=>
string(5) "index"
[2]=>
string(3) "two"
}
array(2) {
["value1"]=>
string(4) "key3"
[2]=>
string(4) "key2"
}
Done
@@ -0,0 +1,72 @@
--TEST--
Test array_reverse() function : basic functionality - simple array for 'array' argument
--FILE--
<?php
/* Prototype : array array_reverse(array $array [, bool $preserve_keys])
* Description: Return input as a new array with the order of the entries reversed
* Source code: ext/standard/array.c
*/
/*
* Testing array_reverse() by giving a simple array for $array argument
*/
echo "*** Testing array_reverse() : basic functionality ***\n";
// Initialise the array
$array = array("a", "green", "red", 'blue', 10, 13.33);
// Calling array_reverse() with default arguments
var_dump( array_reverse($array) );
// Calling array_reverse() with all possible arguments
var_dump( array_reverse($array, true) ); // expects the keys to be preserved
var_dump( array_reverse($array, false) ); // expects the keys not to be preserved
echo "Done";
?>
--EXPECTF--
*** Testing array_reverse() : basic functionality ***
array(6) {
[0]=>
float(13.33)
[1]=>
int(10)
[2]=>
string(4) "blue"
[3]=>
string(3) "red"
[4]=>
string(5) "green"
[5]=>
string(1) "a"
}
array(6) {
[5]=>
float(13.33)
[4]=>
int(10)
[3]=>
string(4) "blue"
[2]=>
string(3) "red"
[1]=>
string(5) "green"
[0]=>
string(1) "a"
}
array(6) {
[0]=>
float(13.33)
[1]=>
int(10)
[2]=>
string(4) "blue"
[3]=>
string(3) "red"
[4]=>
string(5) "green"
[5]=>
string(1) "a"
}
Done
@@ -0,0 +1,60 @@
--TEST--
Test array_reverse() function : basic functionality - associative array for 'array' argument
--FILE--
<?php
/* Prototype : array array_reverse(array $array [, bool $preserve_keys])
* Description: Return input as a new array with the order of the entries reversed
* Source code: ext/standard/array.c
*/
/*
* Testing array_reverse() with associative array for $array argument
*/
echo "*** Testing array_reverse() : basic functionality ***\n";
// Initialise the array
$array = array("a" => "hello", 123 => "number", 'string' => 'blue', "10" => 13.33);
// Calling array_reverse() with default arguments
var_dump( array_reverse($array) );
// Calling array_reverse() with all possible arguments
var_dump( array_reverse($array, true) ); // expects the keys to be preserved
var_dump( array_reverse($array, false) ); // expects the keys not to be preserved
echo "Done";
?>
--EXPECTF--
*** Testing array_reverse() : basic functionality ***
array(4) {
[0]=>
float(13.33)
["string"]=>
string(4) "blue"
[1]=>
string(6) "number"
["a"]=>
string(5) "hello"
}
array(4) {
[10]=>
float(13.33)
["string"]=>
string(4) "blue"
[123]=>
string(6) "number"
["a"]=>
string(5) "hello"
}
array(4) {
[0]=>
float(13.33)
["string"]=>
string(4) "blue"
[1]=>
string(6) "number"
["a"]=>
string(5) "hello"
}
Done
@@ -0,0 +1,40 @@
--TEST--
Test array_reverse() function : error conditions
--FILE--
<?php
/* Prototype : array array_reverse(array $array [, bool $preserve_keys])
* Description: Return input as a new array with the order of the entries reversed
* Source code: ext/standard/array.c
*/
echo "*** Testing array_reverse() : error conditions ***\n";
// zero arguments
echo "\n-- Testing array_reverse() function with Zero arguments --\n";
var_dump( array_reverse() );
// more than the expected number of arguments
echo "\n-- Testing array_diff() function with more than expected no. of arguments --\n";
$array = array(1, 2, 3, 4, 5, 6);
$extra_arg = 10;
var_dump( array_reverse($array, true, $extra_arg) );
var_dump( array_reverse($array, false, $extra_arg) );
echo "Done";
?>
--EXPECTF--
*** Testing array_reverse() : error conditions ***
-- Testing array_reverse() function with Zero arguments --
Warning: Wrong parameter count for array_reverse() in %s on line %d
NULL
-- Testing array_diff() function with more than expected no. of arguments --
Warning: Wrong parameter count for array_reverse() in %s on line %d
NULL
Warning: Wrong parameter count for array_reverse() in %s on line %d
NULL
Done
@@ -0,0 +1,340 @@
--TEST--
Test array_reverse() function : usage variations - unexpected values for 'array' argument
--FILE--
<?php
/* Prototype : array array_reverse(array $array [, bool $preserve_keys])
* Description: Return input as a new array with the order of the entries reversed
* Source code: ext/standard/array.c
*/
echo "*** Testing array_reverse() : usage variations - unexpected values for 'array' argument ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//get a resource variable
$fp = fopen(__FILE__, "r");
//get a class
class classA
{
public function __toString(){
return "Class A object";
}
}
//get a heredoc string
$heredoc_string = <<<EOT
Hello world\t\n
EOT;
//array of values to iterate over
$arrays = array (
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
10.5e10,
10.6E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
// string data
'Hello world',
"Hello world",
$heredoc_string,
// object data
/*21*/ new classA(),
// undefined data
@$undefined_var,
// unset data
@$unset_var,
// resource variable
/*24*/ $fp
);
// loop through each element of the array $arrays to check the behavior of array_reverse()
$iterator = 1;
foreach($arrays as $array) {
echo "\n-- Iteration $iterator --";
// with default argument
var_dump( array_reverse($array) );
// with all possible arguments
var_dump( array_reverse($array, true) );
var_dump( array_reverse($array, false) );
$iterator++;
};
// close the file resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_reverse() : usage variations - unexpected values for 'array' argument ***
-- Iteration 1 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 2 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 3 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 4 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 5 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 6 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 7 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 8 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 9 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 10 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 11 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 12 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 13 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 14 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 15 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 16 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 17 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 18 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 19 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 20 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 21 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 22 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 23 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
-- Iteration 24 --
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Warning: array_reverse(): The argument should be an array in %s on line %d
NULL
Done
@@ -0,0 +1,491 @@
--TEST--
Test array_reverse() function : usage variations - unexpected values for 'preserve_keys' argument
--FILE--
<?php
/* Prototype : array array_reverse(array $array [, bool $preserve_keys])
* Description: Return input as a new array with the order of the entries reversed
* Source code: ext/standard/array.c
*/
/*
* testing the functionality of array_reverse() by giving unexpected values for $preserve_keys argument
*/
echo "*** Testing array_reverse() : usage variations ***\n";
// Initialise the array
$array = array("a" => "green", "red", "blue", "red", "orange", "pink");
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//get a resource variable
$fp = fopen(__FILE__, "r");
//get a class
class classA
{
public function __toString(){
return "Class A object";
}
}
//array of values to iterate over
$preserve_keys = array (
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
10.5e10,
10.6E-10,
.5,
// array data
/*10*/ array(),
array(0),
array(1),
array(1, 2),
array('color' => 'red', 'item' => 'pen'),
// null data
/*15*/ NULL,
null,
// boolean data
true,
false,
TRUE,
FALSE,
// empty data
/*21*/
"",
'',
// object data
new classA(),
// undefined data
@$undefined_var,
// unset data
@$unset_var,
// resource variable
/*26*/ $fp
);
// loop through each element of the array $preserve_keys to check the behavior of array_reverse()
$iterator = 1;
foreach($preserve_keys as $preserve_key) {
echo "-- Iteration $iterator --\n";
var_dump( array_reverse($array, $preserve_key) );
$iterator++;
};
// close the file resouce used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_reverse() : usage variations ***
-- Iteration 1 --
array(6) {
[0]=>
string(4) "pink"
[1]=>
string(6) "orange"
[2]=>
string(3) "red"
[3]=>
string(4) "blue"
[4]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 2 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 3 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 4 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 5 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 6 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 7 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 8 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 9 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 10 --
array(6) {
[0]=>
string(4) "pink"
[1]=>
string(6) "orange"
[2]=>
string(3) "red"
[3]=>
string(4) "blue"
[4]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 11 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 12 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 13 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 14 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 15 --
array(6) {
[0]=>
string(4) "pink"
[1]=>
string(6) "orange"
[2]=>
string(3) "red"
[3]=>
string(4) "blue"
[4]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 16 --
array(6) {
[0]=>
string(4) "pink"
[1]=>
string(6) "orange"
[2]=>
string(3) "red"
[3]=>
string(4) "blue"
[4]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 17 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 18 --
array(6) {
[0]=>
string(4) "pink"
[1]=>
string(6) "orange"
[2]=>
string(3) "red"
[3]=>
string(4) "blue"
[4]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 19 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 20 --
array(6) {
[0]=>
string(4) "pink"
[1]=>
string(6) "orange"
[2]=>
string(3) "red"
[3]=>
string(4) "blue"
[4]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 21 --
array(6) {
[0]=>
string(4) "pink"
[1]=>
string(6) "orange"
[2]=>
string(3) "red"
[3]=>
string(4) "blue"
[4]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 22 --
array(6) {
[0]=>
string(4) "pink"
[1]=>
string(6) "orange"
[2]=>
string(3) "red"
[3]=>
string(4) "blue"
[4]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 23 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 24 --
array(6) {
[0]=>
string(4) "pink"
[1]=>
string(6) "orange"
[2]=>
string(3) "red"
[3]=>
string(4) "blue"
[4]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 25 --
array(6) {
[0]=>
string(4) "pink"
[1]=>
string(6) "orange"
[2]=>
string(3) "red"
[3]=>
string(4) "blue"
[4]=>
string(3) "red"
["a"]=>
string(5) "green"
}
-- Iteration 26 --
array(6) {
[4]=>
string(4) "pink"
[3]=>
string(6) "orange"
[2]=>
string(3) "red"
[1]=>
string(4) "blue"
[0]=>
string(3) "red"
["a"]=>
string(5) "green"
}
Done
@@ -0,0 +1,602 @@
--TEST--
Test array_reverse() function : usage variations - different array values for 'array' argument
--FILE--
<?php
/* Prototype : array array_reverse(array $array [, bool $preserve_keys])
* Description: Return input as a new array with the order of the entries reversed
* Source code: ext/standard/array.c
*/
/*
* Testing the functionality of array_reverse() by giving
* different array values for $array argument
*/
echo "*** Testing array_reverse() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//get a resource variable
$fp = fopen(__FILE__, "r");
//get a class
class classA
{
public function __toString(){
return "Class A object";
}
}
// get a heredoc string
$heredoc = <<<EOT
Hello world
EOT;
$arrays = array (
/*1*/ array(1, 2), // array with default keys and numeric values
array(1.1, 2.2), // array with default keys & float values
array( array(2), array(1)), // sub arrays
array(false,true), // array with default keys and boolean values
array(), // empty array
array(NULL), // array with NULL
array("a","aaaa","b","bbbb","c","ccccc"),
// associative arrays
/*8*/ array(1 => "one", 2 => "two", 3 => "three"), // explicit numeric keys, string values
array("one" => 1, "two" => 2, "three" => 3 ), // string keys & numeric values
array( 1 => 10, 2 => 20, 4 => 40, 3 => 30), // explicit numeric keys and numeric values
array( "one" => "ten", "two" => "twenty", "three" => "thirty"), // string key/value
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*13*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
// array with repetative keys
/*18*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
);
// loop through the various elements of $arrays to test array_reverse()
$iterator = 1;
foreach($arrays as $array) {
echo "-- Iteration $iterator --\n";
// with default argument
echo "- with default argument -\n";
var_dump( array_reverse($array) );
// with all possible arguments
echo "- with \$preserve keys = true -\n";
var_dump( array_reverse($array, true) );
echo "- with \$preserve_keys = false -\n";
var_dump( array_reverse($array, false) );
$iterator++;
};
// close the file resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_reverse() : usage variations ***
-- Iteration 1 --
- with default argument -
array(2) {
[0]=>
int(2)
[1]=>
int(1)
}
- with $preserve keys = true -
array(2) {
[1]=>
int(2)
[0]=>
int(1)
}
- with $preserve_keys = false -
array(2) {
[0]=>
int(2)
[1]=>
int(1)
}
-- Iteration 2 --
- with default argument -
array(2) {
[0]=>
float(2.2)
[1]=>
float(1.1)
}
- with $preserve keys = true -
array(2) {
[1]=>
float(2.2)
[0]=>
float(1.1)
}
- with $preserve_keys = false -
array(2) {
[0]=>
float(2.2)
[1]=>
float(1.1)
}
-- Iteration 3 --
- with default argument -
array(2) {
[0]=>
array(1) {
[0]=>
int(1)
}
[1]=>
array(1) {
[0]=>
int(2)
}
}
- with $preserve keys = true -
array(2) {
[1]=>
array(1) {
[0]=>
int(1)
}
[0]=>
array(1) {
[0]=>
int(2)
}
}
- with $preserve_keys = false -
array(2) {
[0]=>
array(1) {
[0]=>
int(1)
}
[1]=>
array(1) {
[0]=>
int(2)
}
}
-- Iteration 4 --
- with default argument -
array(2) {
[0]=>
bool(true)
[1]=>
bool(false)
}
- with $preserve keys = true -
array(2) {
[1]=>
bool(true)
[0]=>
bool(false)
}
- with $preserve_keys = false -
array(2) {
[0]=>
bool(true)
[1]=>
bool(false)
}
-- Iteration 5 --
- with default argument -
array(0) {
}
- with $preserve keys = true -
array(0) {
}
- with $preserve_keys = false -
array(0) {
}
-- Iteration 6 --
- with default argument -
array(1) {
[0]=>
NULL
}
- with $preserve keys = true -
array(1) {
[0]=>
NULL
}
- with $preserve_keys = false -
array(1) {
[0]=>
NULL
}
-- Iteration 7 --
- with default argument -
array(6) {
[0]=>
string(5) "ccccc"
[1]=>
string(1) "c"
[2]=>
string(4) "bbbb"
[3]=>
string(1) "b"
[4]=>
string(4) "aaaa"
[5]=>
string(1) "a"
}
- with $preserve keys = true -
array(6) {
[5]=>
string(5) "ccccc"
[4]=>
string(1) "c"
[3]=>
string(4) "bbbb"
[2]=>
string(1) "b"
[1]=>
string(4) "aaaa"
[0]=>
string(1) "a"
}
- with $preserve_keys = false -
array(6) {
[0]=>
string(5) "ccccc"
[1]=>
string(1) "c"
[2]=>
string(4) "bbbb"
[3]=>
string(1) "b"
[4]=>
string(4) "aaaa"
[5]=>
string(1) "a"
}
-- Iteration 8 --
- with default argument -
array(3) {
[0]=>
string(5) "three"
[1]=>
string(3) "two"
[2]=>
string(3) "one"
}
- with $preserve keys = true -
array(3) {
[3]=>
string(5) "three"
[2]=>
string(3) "two"
[1]=>
string(3) "one"
}
- with $preserve_keys = false -
array(3) {
[0]=>
string(5) "three"
[1]=>
string(3) "two"
[2]=>
string(3) "one"
}
-- Iteration 9 --
- with default argument -
array(3) {
["three"]=>
int(3)
["two"]=>
int(2)
["one"]=>
int(1)
}
- with $preserve keys = true -
array(3) {
["three"]=>
int(3)
["two"]=>
int(2)
["one"]=>
int(1)
}
- with $preserve_keys = false -
array(3) {
["three"]=>
int(3)
["two"]=>
int(2)
["one"]=>
int(1)
}
-- Iteration 10 --
- with default argument -
array(4) {
[0]=>
int(30)
[1]=>
int(40)
[2]=>
int(20)
[3]=>
int(10)
}
- with $preserve keys = true -
array(4) {
[3]=>
int(30)
[4]=>
int(40)
[2]=>
int(20)
[1]=>
int(10)
}
- with $preserve_keys = false -
array(4) {
[0]=>
int(30)
[1]=>
int(40)
[2]=>
int(20)
[3]=>
int(10)
}
-- Iteration 11 --
- with default argument -
array(3) {
["three"]=>
string(6) "thirty"
["two"]=>
string(6) "twenty"
["one"]=>
string(3) "ten"
}
- with $preserve keys = true -
array(3) {
["three"]=>
string(6) "thirty"
["two"]=>
string(6) "twenty"
["one"]=>
string(3) "ten"
}
- with $preserve_keys = false -
array(3) {
["three"]=>
string(6) "thirty"
["two"]=>
string(6) "twenty"
["one"]=>
string(3) "ten"
}
-- Iteration 12 --
- with default argument -
array(3) {
[0]=>
string(4) "four"
[1]=>
string(3) "two"
["one"]=>
int(1)
}
- with $preserve keys = true -
array(3) {
[4]=>
string(4) "four"
[2]=>
string(3) "two"
["one"]=>
int(1)
}
- with $preserve_keys = false -
array(3) {
[0]=>
string(4) "four"
[1]=>
string(3) "two"
["one"]=>
int(1)
}
-- Iteration 13 --
- with default argument -
array(3) {
["null"]=>
NULL
["NULL"]=>
NULL
[""]=>
string(4) "null"
}
- with $preserve keys = true -
array(3) {
["null"]=>
NULL
["NULL"]=>
NULL
[""]=>
string(4) "null"
}
- with $preserve_keys = false -
array(3) {
["null"]=>
NULL
["NULL"]=>
NULL
[""]=>
string(4) "null"
}
-- Iteration 14 --
- with default argument -
array(4) {
["true"]=>
bool(true)
["false"]=>
bool(false)
[0]=>
string(5) "false"
[1]=>
string(4) "true"
}
- with $preserve keys = true -
array(4) {
["true"]=>
bool(true)
["false"]=>
bool(false)
[0]=>
string(5) "false"
[1]=>
string(4) "true"
}
- with $preserve_keys = false -
array(4) {
["true"]=>
bool(true)
["false"]=>
bool(false)
[0]=>
string(5) "false"
[1]=>
string(4) "true"
}
-- Iteration 15 --
- with default argument -
array(3) {
["emptys"]=>
string(0) ""
["emptyd"]=>
string(0) ""
[""]=>
string(6) "emptys"
}
- with $preserve keys = true -
array(3) {
["emptys"]=>
string(0) ""
["emptyd"]=>
string(0) ""
[""]=>
string(6) "emptys"
}
- with $preserve_keys = false -
array(3) {
["emptys"]=>
string(0) ""
["emptyd"]=>
string(0) ""
[""]=>
string(6) "emptys"
}
-- Iteration 16 --
- with default argument -
array(6) {
[0]=>
bool(true)
[1]=>
bool(false)
[2]=>
NULL
[3]=>
NULL
[4]=>
string(0) ""
[5]=>
string(0) ""
}
- with $preserve keys = true -
array(6) {
[6]=>
bool(true)
[5]=>
bool(false)
[4]=>
NULL
[3]=>
NULL
[2]=>
string(0) ""
[1]=>
string(0) ""
}
- with $preserve_keys = false -
array(6) {
[0]=>
bool(true)
[1]=>
bool(false)
[2]=>
NULL
[3]=>
NULL
[4]=>
string(0) ""
[5]=>
string(0) ""
}
-- Iteration 17 --
- with default argument -
array(3) {
[0]=>
int(6)
[1]=>
int(5)
[""]=>
int(4)
}
- with $preserve keys = true -
array(3) {
[1]=>
int(6)
[0]=>
int(5)
[""]=>
int(4)
}
- with $preserve_keys = false -
array(3) {
[0]=>
int(6)
[1]=>
int(5)
[""]=>
int(4)
}
-- Iteration 18 --
- with default argument -
array(3) {
["three"]=>
int(3)
["two"]=>
int(20)
["One"]=>
int(10)
}
- with $preserve keys = true -
array(3) {
["three"]=>
int(3)
["two"]=>
int(20)
["One"]=>
int(10)
}
- with $preserve_keys = false -
array(3) {
["three"]=>
int(3)
["two"]=>
int(20)
["One"]=>
int(10)
}
Done
@@ -0,0 +1,377 @@
--TEST--
Test array_reverse() function : usage variations - assoc. array with diff. keys for 'array' argument
--FILE--
<?php
/* Prototype : array array_reverse(array $array [, bool $preserve_keys])
* Description: Return input as a new array with the order of the entries reversed
* Source code: ext/standard/array.c
*/
/*
* Testing the functionality of array_reverse() by giving associative arrays with different
* keys for $array argument
*/
echo "*** Testing array_reverse() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//get a resource variable
$fp = fopen(__FILE__, "r");
//get a class
class classA{
public function __toString(){
return "Class A object";
}
}
// get a heredoc string
$heredoc = <<<EOT
Hello world
EOT;
// initializing the array
$arrays = array (
// empty array
/*1*/ array(),
// arrays with integer keys
array(0 => "0"),
array(1 => "1"),
array(1 => "1", 2 => "2", 3 => "3", 4 => "4"),
// arrays with float keys
/*5*/ array(2.3333 => "float"),
array(1.2 => "f1", 3.33 => "f2", 4.89999922839999 => "f3", 33333333.333333 => "f4"),
// arrays with string keys
array("\tHello" => 111, "re\td" => "color", "\v\fworld" => 2.2, "pen\n" => 33),
/*8*/ array("\tHello" => 111, "re\td" => "color", "\v\fworld" => 2.2, "pen\n" => 33),
array("hello", $heredoc => "string"), // heredoc
// array with object, unset variable and resource variable
array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'),
// array with mixed values
/*11*/ array('hello' => 1, new classA() => 2, "fruit" => 2.2, $fp => 'resource', 133 => "int", 444.432 => "float", @$unset_var => "unset", $heredoc => "heredoc")
);
// loop through the various elements of $arrays to test array_reverse()
$iterator = 1;
foreach($arrays as $array) {
echo "-- Iteration $iterator --\n";
// with default argument
echo "- default argument -\n";
var_dump( array_reverse($array) );
// with $preserve_keys argument
echo "- \$preserve keys = true -\n";
var_dump( array_reverse($array, true) );
echo "- \$preserve_keys = false -\n";
var_dump( array_reverse($array, false) );
$iterator++;
};
// close the file resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_reverse() : usage variations ***
Warning: Illegal offset type in %s on line %d
Warning: Illegal offset type in %s on line %d
Warning: Illegal offset type in %s on line %d
Warning: Illegal offset type in %s on line %d
-- Iteration 1 --
- default argument -
array(0) {
}
- $preserve keys = true -
array(0) {
}
- $preserve_keys = false -
array(0) {
}
-- Iteration 2 --
- default argument -
array(1) {
[0]=>
string(1) "0"
}
- $preserve keys = true -
array(1) {
[0]=>
string(1) "0"
}
- $preserve_keys = false -
array(1) {
[0]=>
string(1) "0"
}
-- Iteration 3 --
- default argument -
array(1) {
[0]=>
string(1) "1"
}
- $preserve keys = true -
array(1) {
[1]=>
string(1) "1"
}
- $preserve_keys = false -
array(1) {
[0]=>
string(1) "1"
}
-- Iteration 4 --
- default argument -
array(4) {
[0]=>
string(1) "4"
[1]=>
string(1) "3"
[2]=>
string(1) "2"
[3]=>
string(1) "1"
}
- $preserve keys = true -
array(4) {
[4]=>
string(1) "4"
[3]=>
string(1) "3"
[2]=>
string(1) "2"
[1]=>
string(1) "1"
}
- $preserve_keys = false -
array(4) {
[0]=>
string(1) "4"
[1]=>
string(1) "3"
[2]=>
string(1) "2"
[3]=>
string(1) "1"
}
-- Iteration 5 --
- default argument -
array(1) {
[0]=>
string(5) "float"
}
- $preserve keys = true -
array(1) {
[2]=>
string(5) "float"
}
- $preserve_keys = false -
array(1) {
[0]=>
string(5) "float"
}
-- Iteration 6 --
- default argument -
array(4) {
[0]=>
string(2) "f4"
[1]=>
string(2) "f3"
[2]=>
string(2) "f2"
[3]=>
string(2) "f1"
}
- $preserve keys = true -
array(4) {
[33333333]=>
string(2) "f4"
[4]=>
string(2) "f3"
[3]=>
string(2) "f2"
[1]=>
string(2) "f1"
}
- $preserve_keys = false -
array(4) {
[0]=>
string(2) "f4"
[1]=>
string(2) "f3"
[2]=>
string(2) "f2"
[3]=>
string(2) "f1"
}
-- Iteration 7 --
- default argument -
array(4) {
["pen
"]=>
int(33)
[" world"]=>
float(2.2)
["re d"]=>
string(5) "color"
[" Hello"]=>
int(111)
}
- $preserve keys = true -
array(4) {
["pen
"]=>
int(33)
[" world"]=>
float(2.2)
["re d"]=>
string(5) "color"
[" Hello"]=>
int(111)
}
- $preserve_keys = false -
array(4) {
["pen
"]=>
int(33)
[" world"]=>
float(2.2)
["re d"]=>
string(5) "color"
[" Hello"]=>
int(111)
}
-- Iteration 8 --
- default argument -
array(4) {
["pen
"]=>
int(33)
[" world"]=>
float(2.2)
["re d"]=>
string(5) "color"
[" Hello"]=>
int(111)
}
- $preserve keys = true -
array(4) {
["pen
"]=>
int(33)
[" world"]=>
float(2.2)
["re d"]=>
string(5) "color"
[" Hello"]=>
int(111)
}
- $preserve_keys = false -
array(4) {
["pen
"]=>
int(33)
[" world"]=>
float(2.2)
["re d"]=>
string(5) "color"
[" Hello"]=>
int(111)
}
-- Iteration 9 --
- default argument -
array(2) {
["Hello world"]=>
string(6) "string"
[0]=>
string(5) "hello"
}
- $preserve keys = true -
array(2) {
["Hello world"]=>
string(6) "string"
[0]=>
string(5) "hello"
}
- $preserve_keys = false -
array(2) {
["Hello world"]=>
string(6) "string"
[0]=>
string(5) "hello"
}
-- Iteration 10 --
- default argument -
array(1) {
[""]=>
string(5) "hello"
}
- $preserve keys = true -
array(1) {
[""]=>
string(5) "hello"
}
- $preserve_keys = false -
array(1) {
[""]=>
string(5) "hello"
}
-- Iteration 11 --
- default argument -
array(6) {
["Hello world"]=>
string(7) "heredoc"
[""]=>
string(5) "unset"
[0]=>
string(5) "float"
[1]=>
string(3) "int"
["fruit"]=>
float(2.2)
["hello"]=>
int(1)
}
- $preserve keys = true -
array(6) {
["Hello world"]=>
string(7) "heredoc"
[""]=>
string(5) "unset"
[444]=>
string(5) "float"
[133]=>
string(3) "int"
["fruit"]=>
float(2.2)
["hello"]=>
int(1)
}
- $preserve_keys = false -
array(6) {
["Hello world"]=>
string(7) "heredoc"
[""]=>
string(5) "unset"
[0]=>
string(5) "float"
[1]=>
string(3) "int"
["fruit"]=>
float(2.2)
["hello"]=>
int(1)
}
Done
@@ -0,0 +1,397 @@
--TEST--
Test array_reverse() function : usage variations - assoc. array with diff. value for 'array' argument
--FILE--
<?php
/* Prototype : array array_reverse(array $array [, bool $preserve_keys])
* Description: Return input as a new array with the order of the entries reversed
* Source code: ext/standard/array.c
*/
/*
* Testing the functionality of array_reverse() by giving associative arrays with different
* values for $array argument
*/
echo "*** Testing array_reverse() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//get a resource variable
$fp = fopen(__FILE__, "r");
//get a class
class classA
{
public function __toString(){
return "Class A object";
}
}
// get a heredoc string
$heredoc = <<<EOT
Hello world
EOT;
// initializing the array
$arrays = array (
// empty array
/*1*/ array(),
// arrays with integer values
array('0' => 0),
array("1" => 1),
array("one" => 1, 'two' => 2, "three" => 3, 4 => 4),
// arrays with float values
/*5*/ array("float" => 2.3333),
array("f1" => 1.2, 'f2' => 3.33, 3 => 4.89999922839999, 'f4' => 33333333.333333),
// arrays with string values
array(111 => "\tHello", "red" => "col\tor", 2 => "\v\fworld", 3.3 => "pen\n"),
/*8*/ array(111 => '\tHello', "red" => 'col\tor', 2 => '\v\fworld', 3.3 => 'pen\n'),
array(1 => "hello", "heredoc" => $heredoc),
// array with object, unset variable and resource variable
array(11 => new classA(), "unset" => @$unset_var, "resource" => $fp),
// array with mixed values
/*11*/ array(1 => 'hello', 2 => new classA(), 222 => "fruit", 'resource' => $fp, "int" => 133, "float" => 444.432, "unset" => @$unset_var, "heredoc" => $heredoc)
);
// loop through the various elements of $arrays to test array_reverse()
$iterator = 1;
foreach($arrays as $array) {
echo "-- Iteration $iterator --\n";
// with default argument
echo "- default argument -\n";
var_dump( array_reverse($array) );
// with $preserve_keys argument
echo "- \$preserve keys = true -\n";
var_dump( array_reverse($array, true) );
echo "- \$preserve_keys = false -\n";
var_dump( array_reverse($array, false) );
$iterator++;
};
// close the file resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_reverse() : usage variations ***
-- Iteration 1 --
- default argument -
array(0) {
}
- $preserve keys = true -
array(0) {
}
- $preserve_keys = false -
array(0) {
}
-- Iteration 2 --
- default argument -
array(1) {
[0]=>
int(0)
}
- $preserve keys = true -
array(1) {
[0]=>
int(0)
}
- $preserve_keys = false -
array(1) {
[0]=>
int(0)
}
-- Iteration 3 --
- default argument -
array(1) {
[0]=>
int(1)
}
- $preserve keys = true -
array(1) {
[1]=>
int(1)
}
- $preserve_keys = false -
array(1) {
[0]=>
int(1)
}
-- Iteration 4 --
- default argument -
array(4) {
[0]=>
int(4)
["three"]=>
int(3)
["two"]=>
int(2)
["one"]=>
int(1)
}
- $preserve keys = true -
array(4) {
[4]=>
int(4)
["three"]=>
int(3)
["two"]=>
int(2)
["one"]=>
int(1)
}
- $preserve_keys = false -
array(4) {
[0]=>
int(4)
["three"]=>
int(3)
["two"]=>
int(2)
["one"]=>
int(1)
}
-- Iteration 5 --
- default argument -
array(1) {
["float"]=>
float(2.3333)
}
- $preserve keys = true -
array(1) {
["float"]=>
float(2.3333)
}
- $preserve_keys = false -
array(1) {
["float"]=>
float(2.3333)
}
-- Iteration 6 --
- default argument -
array(4) {
["f4"]=>
float(33333333.333333)
[0]=>
float(4.8999992284)
["f2"]=>
float(3.33)
["f1"]=>
float(1.2)
}
- $preserve keys = true -
array(4) {
["f4"]=>
float(33333333.333333)
[3]=>
float(4.8999992284)
["f2"]=>
float(3.33)
["f1"]=>
float(1.2)
}
- $preserve_keys = false -
array(4) {
["f4"]=>
float(33333333.333333)
[0]=>
float(4.8999992284)
["f2"]=>
float(3.33)
["f1"]=>
float(1.2)
}
-- Iteration 7 --
- default argument -
array(4) {
[0]=>
string(4) "pen
"
[1]=>
string(7) " world"
["red"]=>
string(6) "col or"
[2]=>
string(6) " Hello"
}
- $preserve keys = true -
array(4) {
[3]=>
string(4) "pen
"
[2]=>
string(7) " world"
["red"]=>
string(6) "col or"
[111]=>
string(6) " Hello"
}
- $preserve_keys = false -
array(4) {
[0]=>
string(4) "pen
"
[1]=>
string(7) " world"
["red"]=>
string(6) "col or"
[2]=>
string(6) " Hello"
}
-- Iteration 8 --
- default argument -
array(4) {
[0]=>
string(5) "pen\n"
[1]=>
string(9) "\v\fworld"
["red"]=>
string(7) "col\tor"
[2]=>
string(7) "\tHello"
}
- $preserve keys = true -
array(4) {
[3]=>
string(5) "pen\n"
[2]=>
string(9) "\v\fworld"
["red"]=>
string(7) "col\tor"
[111]=>
string(7) "\tHello"
}
- $preserve_keys = false -
array(4) {
[0]=>
string(5) "pen\n"
[1]=>
string(9) "\v\fworld"
["red"]=>
string(7) "col\tor"
[2]=>
string(7) "\tHello"
}
-- Iteration 9 --
- default argument -
array(2) {
["heredoc"]=>
string(11) "Hello world"
[0]=>
string(5) "hello"
}
- $preserve keys = true -
array(2) {
["heredoc"]=>
string(11) "Hello world"
[1]=>
string(5) "hello"
}
- $preserve_keys = false -
array(2) {
["heredoc"]=>
string(11) "Hello world"
[0]=>
string(5) "hello"
}
-- Iteration 10 --
- default argument -
array(3) {
["resource"]=>
resource(%d) of type (stream)
["unset"]=>
NULL
[0]=>
object(classA)#%d (0) {
}
}
- $preserve keys = true -
array(3) {
["resource"]=>
resource(%d) of type (stream)
["unset"]=>
NULL
[11]=>
object(classA)#%d (0) {
}
}
- $preserve_keys = false -
array(3) {
["resource"]=>
resource(%d) of type (stream)
["unset"]=>
NULL
[0]=>
object(classA)#%d (0) {
}
}
-- Iteration 11 --
- default argument -
array(8) {
["heredoc"]=>
string(11) "Hello world"
["unset"]=>
NULL
["float"]=>
float(444.432)
["int"]=>
int(133)
["resource"]=>
resource(%d) of type (stream)
[0]=>
string(5) "fruit"
[1]=>
object(classA)#%d (0) {
}
[2]=>
string(5) "hello"
}
- $preserve keys = true -
array(8) {
["heredoc"]=>
string(11) "Hello world"
["unset"]=>
NULL
["float"]=>
float(444.432)
["int"]=>
int(133)
["resource"]=>
resource(%d) of type (stream)
[222]=>
string(5) "fruit"
[2]=>
object(classA)#%d (0) {
}
[1]=>
string(5) "hello"
}
- $preserve_keys = false -
array(8) {
["heredoc"]=>
string(11) "Hello world"
["unset"]=>
NULL
["float"]=>
float(444.432)
["int"]=>
int(133)
["resource"]=>
resource(%d) of type (stream)
[0]=>
string(5) "fruit"
[1]=>
object(classA)#%d (0) {
}
[2]=>
string(5) "hello"
}
Done
@@ -0,0 +1,209 @@
--TEST--
Test array_reverse() function : usage variations - two dimensional arrays for 'array' argument
--FILE--
<?php
/* Prototype : array array_reverse(array $array [, bool $preserve_keys])
* Description: Return input as a new array with the order of the entries reversed
* Source code: ext/standard/array.c
*/
/*
* testing the functionality of array_reverse() by giving 2-D arrays for $array argument
*/
echo "*** Testing array_reverse() : usage variations ***\n";
// Initializing the 2-d arrays
$two_dimensional_array = array(
// associative array
array('color' => 'red', 'item' => 'pen', 'place' => 'LA'),
// numeric array
array(1, 2, 3, 4, 5),
// combination of numeric and associative arrays
array('a' => 'green', 'red', 'brown', 33, 88, 'orange', 'item' => 'ball')
);
// calling array_reverse() with various types of 2-d arrays
// with default arguments
echo "-- with default argument --\n";
var_dump( array_reverse($two_dimensional_array) ); // whole array
var_dump( array_reverse($two_dimensional_array[1]) ); // sub array
// with $preserve_keys argument
echo "-- with all possible arguments --\n";
// whole array
var_dump( array_reverse($two_dimensional_array, true) );
var_dump( array_reverse($two_dimensional_array, false) );
// sub array
var_dump( array_reverse($two_dimensional_array[1], true) );
var_dump( array_reverse($two_dimensional_array[1], false) );
echo "Done";
?>
--EXPECTF--
*** Testing array_reverse() : usage variations ***
-- with default argument --
array(3) {
[0]=>
array(7) {
["a"]=>
string(5) "green"
[0]=>
string(3) "red"
[1]=>
string(5) "brown"
[2]=>
int(33)
[3]=>
int(88)
[4]=>
string(6) "orange"
["item"]=>
string(4) "ball"
}
[1]=>
array(5) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
[4]=>
int(5)
}
[2]=>
array(3) {
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
["place"]=>
string(2) "LA"
}
}
array(5) {
[0]=>
int(5)
[1]=>
int(4)
[2]=>
int(3)
[3]=>
int(2)
[4]=>
int(1)
}
-- with all possible arguments --
array(3) {
[2]=>
array(7) {
["a"]=>
string(5) "green"
[0]=>
string(3) "red"
[1]=>
string(5) "brown"
[2]=>
int(33)
[3]=>
int(88)
[4]=>
string(6) "orange"
["item"]=>
string(4) "ball"
}
[1]=>
array(5) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
[4]=>
int(5)
}
[0]=>
array(3) {
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
["place"]=>
string(2) "LA"
}
}
array(3) {
[0]=>
array(7) {
["a"]=>
string(5) "green"
[0]=>
string(3) "red"
[1]=>
string(5) "brown"
[2]=>
int(33)
[3]=>
int(88)
[4]=>
string(6) "orange"
["item"]=>
string(4) "ball"
}
[1]=>
array(5) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
[4]=>
int(5)
}
[2]=>
array(3) {
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
["place"]=>
string(2) "LA"
}
}
array(5) {
[4]=>
int(5)
[3]=>
int(4)
[2]=>
int(3)
[1]=>
int(2)
[0]=>
int(1)
}
array(5) {
[0]=>
int(5)
[1]=>
int(4)
[2]=>
int(3)
[3]=>
int(2)
[4]=>
int(1)
}
Done
+1 -1
View File
@@ -42,7 +42,7 @@ unlink(dirname(__FILE__)."/007_variation1.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'r' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
string(20) "line
+1 -1
View File
@@ -44,7 +44,7 @@ unlink(dirname(__FILE__)."/007_variation10.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'r+t' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
string(20) "line
@@ -61,7 +61,7 @@ unlink(dirname(__FILE__)."/007_variation11.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'wt' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -61,7 +61,7 @@ unlink(dirname(__FILE__)."/007_variation11.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'wt' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
@@ -61,7 +61,7 @@ unlink(dirname(__FILE__)."/007_variation12.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'w+t' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -61,7 +61,7 @@ unlink(dirname(__FILE__)."/007_variation12.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'w+t' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
@@ -53,7 +53,7 @@ unlink(dirname(__FILE__)."/007_variation13.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'at' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(37)
string(0) ""
+1 -1
View File
@@ -53,7 +53,7 @@ unlink(dirname(__FILE__)."/007_variation13.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'at' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(37)
string(0) ""
+1 -1
View File
@@ -47,7 +47,7 @@ unlink(dirname(__FILE__)."/007_variation14.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'a+t' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(37)
string(57) "line
+1 -1
View File
@@ -44,7 +44,7 @@ unlink(dirname(__FILE__)."/007_variation15.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'xt' mode ***
resource(5) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -44,7 +44,7 @@ unlink(dirname(__FILE__)."/007_variation16.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'x+t' mode ***
resource(5) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -42,7 +42,7 @@ unlink(dirname(__FILE__)."/007_variation17.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'rb' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
string(20) "line
+1 -1
View File
@@ -44,7 +44,7 @@ unlink(dirname(__FILE__)."/007_variation18.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'r+b' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
string(20) "line
+1 -1
View File
@@ -56,7 +56,7 @@ unlink(dirname(__FILE__)."/007_variation19.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'wb' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -44,7 +44,7 @@ unlink(dirname(__FILE__)."/007_variation2.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'r+' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
string(20) "line
+1 -1
View File
@@ -56,7 +56,7 @@ unlink(dirname(__FILE__)."/007_variation20.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'w+b' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -48,7 +48,7 @@ unlink(dirname(__FILE__)."/007_variation21.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'ab' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(37)
string(0) ""
+1 -1
View File
@@ -47,7 +47,7 @@ unlink(dirname(__FILE__)."/007_variation22.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'a+b' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(37)
string(57) "line
+1 -1
View File
@@ -44,7 +44,7 @@ unlink(dirname(__FILE__)."/007_variation23.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'xb' mode ***
resource(5) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -44,7 +44,7 @@ unlink(dirname(__FILE__)."/007_variation24.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'x+b' mode ***
resource(5) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -56,7 +56,7 @@ unlink(dirname(__FILE__)."/007_variation3.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'w' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -56,7 +56,7 @@ unlink(dirname(__FILE__)."/007_variation4.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'w+' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -48,7 +48,7 @@ unlink(dirname(__FILE__)."/007_variation5.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'a' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(37)
string(0) ""
+1 -1
View File
@@ -47,7 +47,7 @@ unlink(dirname(__FILE__)."/007_variation6.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'a+' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(37)
string(57) "line
+1 -1
View File
@@ -44,7 +44,7 @@ unlink(dirname(__FILE__)."/007_variation7.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'x' mode ***
resource(5) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -44,7 +44,7 @@ unlink(dirname(__FILE__)."/007_variation8.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'x+' mode ***
resource(5) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
int(37)
+1 -1
View File
@@ -42,7 +42,7 @@ unlink(dirname(__FILE__)."/007_variation9.tmp");
?>
--EXPECTF--
*** Test fopen() & fclose() functions: with 'rt' mode ***
resource(8) of type (stream)
resource(%d) of type (stream)
string(6) "stream"
int(0)
string(20) "line
+3 -3
View File
@@ -21,7 +21,7 @@ for($outerloop_counter = 0; $outerloop_counter < count($file_content_types); $ou
echo $outerloop_counter + 1;
echo " ---\n";
// create file file
create_files(dirname(__FILE__), 1, $file_content_types[$outerloop_counter]);
create_files(dirname(__FILE__), 1, $file_content_types[$outerloop_counter], 0755, 1, "w", "fgetc_basic", 1);
//open the file in different modes and check the working of fgetc
for($innerloop_counter = 0; $innerloop_counter < count($file_modes); $innerloop_counter++) {
@@ -32,7 +32,7 @@ for($outerloop_counter = 0; $outerloop_counter < count($file_content_types); $ou
echo " --\n";
// open the file using the $file_modes
$filename = dirname(__FILE__)."/file1.tmp"; // file name that is created by create_files
$filename = dirname(__FILE__)."/fgetc_basic1.tmp"; // file name that is created by create_files
echo "-- Testing fgetc() : file opened using $file_modes[$innerloop_counter] mode --\n";
$file_handle = fopen($filename, $file_modes[$innerloop_counter]);
if ( !$file_handle ) {
@@ -55,7 +55,7 @@ for($outerloop_counter = 0; $outerloop_counter < count($file_content_types); $ou
} // end of innerloop for
// delete the file
delete_files(dirname(__FILE__), 1);
delete_files(dirname(__FILE__), 1, "fgetc_basic", 1, ".tmp");
} // end of outerloop for
@@ -0,0 +1,804 @@
--TEST--
Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, default whence
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) != "WIN" )
die("skip.. only valid for Windows");
?>
--FILE--
<?php
/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
Description: Seeks on a file pointer
Prototype: bool rewind ( resource $handle );
Description: Rewind the position of a file pointer
Prototype: int ftell ( resource $handle );
Description: Tells file pointer read/write position
*/
// include the file.inc for common functions for test
include ("file.inc");
/* Testing fseek(),ftell(),rewind() functions
1. All write and create with write modes
2. Testing fseek() without using argument whence
*/
echo "*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***\n";
$file_modes = array( "w","wb","wt","w+","w+b","w+t",
"x","xb","xt","x+","x+b","x+t");
$file_content_types = array( "text_with_new_line","alphanumeric");
$offset = array(-1, 0, 1, 513); // different offsets, including negative and beyond size
$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation2.tmp"; // this is name of the file created by create_files()
/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
foreach($file_content_types as $file_content_type){
echo "\n-- File having data of type ". $file_content_type ." --\n";
foreach($file_modes as $file_mode) {
echo "-- File opened in mode ".$file_mode." --\n";
$file_handle = fopen($filename, $file_mode);
if (!$file_handle){
echo "Error: failed to fopen() file: $filename!";
exit();
}
$data_to_be_written="";
fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
$data_to_be_written = $data_to_be_written;
fwrite($file_handle,(binary)$data_to_be_written);
rewind($file_handle);
echo "-- Testing fseek() without using argument whence --\n";
foreach($offset as $count){
var_dump( fseek($file_handle,$count) );
var_dump( ftell($file_handle) ); // confirm the file pointer position
var_dump( feof($file_handle) ); //ensure that file pointer is not at end
} //end of offset loop
//close the file and check the size
fclose($file_handle);
var_dump( filesize($filename) );
delete_file($filename); // delete file with name
} //end of file_mode loop
} //end of file_content_types loop
echo "Done\n";
?>
--EXPECTF--
*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***
-- File having data of type text_with_new_line --
-- File opened in mode w --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode wb --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode wt --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(569)
-- File opened in mode w+ --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode w+b --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode w+t --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(569)
-- File opened in mode x --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode xb --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode xt --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(569)
-- File opened in mode x+ --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x+b --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x+t --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(569)
-- File having data of type alphanumeric --
-- File opened in mode w --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode wb --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode wt --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode w+ --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode w+b --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode w+t --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode xb --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode xt --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x+ --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x+b --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x+t --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
Done
--UEXPECTF--
*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***
-- File having data of type text_with_new_line --
-- File opened in mode w --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode wb --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode wt --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(569)
-- File opened in mode w+ --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode w+b --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode w+t --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(569)
-- File opened in mode x --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode xb --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode xt --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(569)
-- File opened in mode x+ --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x+b --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x+t --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(569)
-- File having data of type alphanumeric --
-- File opened in mode w --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode wb --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode wt --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode w+ --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode w+b --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode w+t --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode xb --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode xt --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x+ --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x+b --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
-- File opened in mode x+t --
-- Testing fseek() without using argument whence --
int(-1)
int(0)
bool(false)
int(0)
int(0)
bool(false)
int(0)
int(1)
bool(false)
int(0)
int(513)
bool(false)
int(512)
Done
@@ -24,6 +24,7 @@ echo "*** Testing lstat() & stat() : basic functionality ***\n";
// creating dir
$dirname = "$file_path/lstat_stat_basic";
@rmdir($dirname);
mkdir($dirname);
// stat of the dir created
$dir_stat = stat($dirname);
@@ -39,7 +39,7 @@ Notice: import_request_variables(): No prefix specified - possible security haza
Warning: import_request_variables(): Attempted GLOBALS variable overwrite in %s on line %d
Warning: import_request_variables(): Numeric key detected - possible security hazard. in %s on line %d
Warning: import_request_variables(): Numeric key detected - possible security hazard in %s on line %d
NULL
Notice: Undefined variable: ap in %s on line %d
@@ -162,7 +162,7 @@ string(0) ""
-- Iteration 23 --
string(7) "obj\'ct"
-- Iteration 24 --
string(14) "Resource id #%d"
string(%d) "Resource id #%d"
-- Iteration 25 --
string(0) ""
-- Iteration 26 --
+6 -6
View File
@@ -32,25 +32,25 @@ string(6) "abcdex"
bool(false)
bool(false)
Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s on line %d
Warning: substr_count(): Offset value 2147483647 exceeds string length in %s on line %d
bool(false)
Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d
bool(false)
Warning: stripos(): Offset not contained in string. in %s on line %d
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s on line %d
Warning: substr_count(): Offset value 2147483647 exceeds string length in %s on line %d
bool(false)
Warning: substr_count(): Length value 2147483647 exceeds string length. in %s on line %d
Warning: substr_count(): Length value 2147483647 exceeds string length in %s on line %d
bool(false)
Warning: strpos(): Offset not contained in string. in %s on line %d
Warning: strpos(): Offset not contained in string in %s on line %d
bool(false)
Warning: stripos(): Offset not contained in string. in %s on line %d
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
Notice: strrpos(): Offset is greater than the length of haystack string in %s on line %d
@@ -205,6 +205,6 @@ string(0) ""
string(16) " @#$%Object @#$%"
string(11) " @#$%Object"
-- Iteration 26 --
string(14) "Resource id #%d"
string(%d) "Resource id #%d"
string(11) "Resource id"
Done
@@ -0,0 +1,53 @@
--TEST--
Test chunk_split() function : basic functionality
--FILE--
<?php
/* Prototype : string chunk_split(string $str [, int $chunklen [, string $ending]])
* Description: Returns split line
* Source code: ext/standard/string.c
* Alias to functions:
*/
/*
* Testing chunk_split() for basic functionality by passing all possible
* arguments as well as with default arguments chunklen and ending
*/
echo "*** Testing chunk_split() : basic functionality ***\n";
// Initialise all required variables
$str = 'Testing';
$chunklen = 2;
$ending = '##';
// Calling chunk_split() with all possible arguments
echo "-- Testing chunk_split() with all possible arguments --\n";
var_dump( chunk_split($str, $chunklen, $ending) );
// Calling chunk_split() with default ending string
echo "-- Testing chunk_split() with default ending string --\n";
var_dump( chunk_split($str, $chunklen) );
//Calling chunk_split() with default chunklen and ending string
echo "-- Testing chunk_split() with default chunklen and ending string --\n";
var_dump( chunk_split($str) );
echo "Done"
?>
--EXPECTF--
*** Testing chunk_split() : basic functionality ***
-- Testing chunk_split() with all possible arguments --
string(15) "Te##st##in##g##"
-- Testing chunk_split() with default ending string --
string(15) "Te
st
in
g
"
-- Testing chunk_split() with default chunklen and ending string --
string(9) "Testing
"
Done
Loaded 100 of 360 files, more files were not shown because too many files have changed in this diff. Show more