Compare commits

...
Author SHA1 Message Date
SVN Migration b30fdad9a4 This commit was manufactured by cvs2svn to create tag 'php_5_2_5RC2'. 2007-11-01 22:33:32 +00:00
Ilia Alshanetsky e3eb1b9bed 5.2.5RC2 2007-11-01 22:33:31 +00:00
Antony Dovgal f6966f28d0 MFH: initialize correct variable 2007-11-01 19:13:49 +00:00
Jani Taskinen e207cc58ac MFH: nuke unused variables 2007-11-01 17:32:26 +00:00
Dmitry Stogov 67f6979df2 Another fix for bug #42773 2007-11-01 15:41:13 +00:00
Dmitry Stogov e468aa44a2 Fixed bug #42848 (Status: header incorrect under FastCGI) 2007-11-01 15:23:14 +00:00
Dmitry Stogov fc6d3652f9 Fixed bug #41635 (SoapServer and zlib.output_compression with FastCGI result in major slowdown) 2007-11-01 14:11:47 +00:00
Dmitry Stogov 375bf36e42 Fixed bug #42773 (WSDL error causes HTTP 500 Response) 2007-11-01 14:10:19 +00:00
Robert Nicholson 997925db9f delete .project file 2007-11-01 10:34:38 +00:00
Robert Nicholson fa0e4863a2 update min_error and max_error testcases to take into account bug fix for bug#43125 2007-11-01 08:42:32 +00:00
Dmitry Stogov 2e869a00ac Added CGI SAPI -T option, to measure execution time of script repeated several times. 2007-10-31 18:24:42 +00:00
Jani Taskinen 171184b64d MFH: fix typo 2007-10-31 13:39:14 +00:00
Jani Taskinen bdbcc4b6d3 MFH: - Fixed Bug #43137 (rmdir() and rename() do not clear statcache) 2007-10-31 13:23:07 +00:00
Ilia Alshanetsky f4cd343b6c MFB: Fixed bug #43139 PDO ignores ATTR_DEFAULT_FETCH_MODE in some cases with
fetchAll()
2007-10-31 12:58:24 +00:00
Ilia Alshanetsky e5db0d8077 MFB: Test not relavent for sqlite that uses built-in bound syntax 2007-10-30 23:03:54 +00:00
Ilia Alshanetsky 68893b0cb4 MFB: Fixed bug #43130 (Bound parameters cannot have - in their name) 2007-10-29 22:37:25 +00:00
Jani Taskinen caa0de9205 MFH 2007-10-29 09:05:55 +00:00
Ilia Alshanetsky 39f1f2fcd3 MFB: Fixed bug #42976 (Crash when constructor for newInstance() or
newInstanceArgs() fails)
2007-10-28 13:47:14 +00:00
Raghubansh Kumar b89ab4a4d5 New testcases for shuffle() function 2007-10-27 12:29:25 +00:00
Raghubansh Kumar 6d9165b332 New testcases for array_intersect() function 2007-10-27 12:16:57 +00:00
Stanislav Malyshev b196fbece9 add attribution 2007-10-26 17:45:26 +00:00
Robert Nicholson 85122b5ae6 Remove unneeded INI sections 2007-10-26 16:08:34 +00:00
Raghubansh Kumar 8ba0f7f275 more testcases for array_unshift() function 2007-10-26 11:47:50 +00:00
Robert Nicholson 8ae4fa2810 new testcases for array_splice 2007-10-26 11:07:31 +00:00
Robert Nicholson b6900cb61d new testcases for max and min 2007-10-26 11:02:04 +00:00
Jani Taskinen 9a6012ff21 fix news 2007-10-26 08:13:15 +00:00
Antony Dovgal ef0652c7f3 MFH 2007-10-25 13:01:16 +00:00
Antony Dovgal 54e44a4707 MFH 2007-10-25 11:54:23 +00:00
Dmitry Stogov 602f26dc08 Added ability to control memory consumption between request using ZEND_MM_COMPACT environment variable 2007-10-25 07:30:29 +00:00
Ilia Alshanetsky 68f328560d MFB: Fixed bug #43099 (XMLWriter::endElement() does not check # of params) 2007-10-24 22:50:19 +00:00
Dmitry Stogov 1155200b02 Fixed realpath cache for existent file with CWD_FILEPATH flag on win32 2007-10-23 05:57:35 +00:00
Mattias Bengtsson a04472df2e - Be paranoid and dont allow multiplication with zero 2007-10-23 01:58:08 +00:00
Ilia Alshanetsky 521048a9ae MFB: Fixed bug #4294 (Move *timeout initialization from RINIT to connect
time)
2007-10-22 22:43:44 +00:00
Raghubansh Kumar 4846f7e349 more testcase for array_filter() function 2007-10-22 11:13:51 +00:00
Andrey Hristov 7c21b37a2f Make it compile with libmysql 3.23 2007-10-22 10:35:33 +00:00
Dmitry Stogov f8e5189286 forgotten description 2007-10-22 07:52:03 +00:00
Dmitry Stogov 9926736605 Fixed move_uploaded_file() to always set file permissions of resulting file according to UMASK (Andrew Sitnikov) 2007-10-22 07:37:20 +00:00
Ilia Alshanetsky 0139100668 MFB: Fixed bug #42944 (test failing due to expectation that /etc/passwd has
0644 permissions).
2007-10-21 15:41:45 +00:00
Raghubansh Kumar 083c7f05ca New tetscases for array_rand() function 2007-10-19 18:39:52 +00:00
Raghubansh Kumar ff9f6404dd New testcases for array_fill() function 2007-10-19 18:34:16 +00:00
Raghubansh Kumar ee0c90556e New testcases for array_filter() function 2007-10-19 18:18:17 +00:00
Raghubansh Kumar 5516f0a247 New testcases for array_unshift() function 2007-10-19 09:12:22 +00:00
Robert Thompson 586ceb9d40 formatting 2007-10-19 05:35:05 +00:00
Robert Thompson 08433295c4 News for getcwd() failure fix. 2007-10-19 01:22:24 +00:00
Ilia Alshanetsky c6ec417654 Back to dev 2007-10-18 23:09:54 +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
463 changed files with 50532 additions and 1664 deletions

No files matched your search

+50 -4
View File
@@ -1,6 +1,12 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 20??, PHP 5.2.5
01 Nov 2007, PHP 5.2.5RC2
- Added ability to control memory consumption between request using
ZEND_MM_COMPACT environment variable. (Dmitry)
- Fixed bug #43137 (rmdir() and rename() do not clear statcache). (Jani)
- Fixed bug #42773 (WSDL error causes HTTP 500 Response). (Dmitry)
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 +15,9 @@ PHP NEWS
array_uintersect_assoc(), array_diff_key(), array_diff_assoc() and
array_udiff_assoc(). (Dmitry)
- Fixed move_uploaded_file() to always set file permissions of resulting file
according to UMASK. (Andrew Sitnikov)
- 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
@@ -19,22 +28,56 @@ PHP NEWS
- Fixed dl() to limit argument size to MAXPATHLEN (CVE-2007-4887).
(Christian Hoffmann)
- Fixed iconv_*() functions to limit argument sizes as workaround to libc
bug (CVE-2007-4783, CVE-2007-4840). (Christian Hoffmann, Stas)
bug (CVE-2007-4783, CVE-2007-4840 by Laurent Gaffie).
(Christian Hoffmann, Stas)
- Fixed missing brackets leading to build warning and error in the log.
Win32 code). (Andrey)
Win32 code. (Andrey)
- Fixed leaks with multiple connects on one mysqli object. (Andrey)
- Fixed endianness detection on MacOS when building universal binary.
(Uwe Schindler, Christian Speich, Tony)
- Fixed possible triggering of buffer overflows inside glibc
implementations of the fnmatch(), setlocale() and glob() functions.
Reported by Laurent gaffie. (Ilia)
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 #43139 (PDO ignores ATTR_DEFAULT_FETCH_MODE in some cases with
fetchAll()). (Ilia)
- Fixed bug #43130 (Bound parameters cannot have - in their name). (Ilia)
- Fixed bug #43099 (XMLWriter::endElement() does not check # of params).
(Ilia)
- Fixed bug #43020 (Warning message is missing with shuffle() and more
than one argument). (Scott)
- Fixed bug #42976 (Crash when constructor for newInstance() or
newInstanceArgs() fails) (Ilia)
- Fixed bug #42943 (ext/mssql: Move *timeout initialization from RINIT
to connect time). (Ilia)
- 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).
@@ -69,6 +112,8 @@ PHP NEWS
- Fixed bug #42139 (XMLReader option constants are broken using XML()). (Rob)
- Fixed bug #42086 (SoapServer return Procedure '' not present for WSIBasic
compliant wsdl). (Dmitry)
- Fixed bug #41822 (Relative includes broken when getcwd() fails). (Ab5602,
Jani)
- Fixed bug #41561 (Values set with php_admin_* in httpd.conf can be overwritten
with ini_set()). (Stas, Jani)
- Fixed bug #39651 (proc_open() append mode doesn't work on windows). (Nuno)
@@ -150,6 +195,7 @@ PHP NEWS
- Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory
already exists). (Pierre)
- Fixed bug #42848 (Status: header incorrect under FastCGI). (Dmitry)
- Fixed bug #42368 (Incorrect error message displayed by pg_escape_string).
(Ilia)
- Fixed bug #42365 (glob() crashes and/or accepts way too many flags).
+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
+8 -3
View File
@@ -489,6 +489,9 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
int ret;
int use_cache;
int use_relative_path = 0;
#ifdef TSRM_WIN32
int is_unc;
#endif
TSRMLS_FETCH();
use_cache = ((use_realpath != CWD_EXPAND) && CWDG(realpath_cache_size_limit));
@@ -573,9 +576,6 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
char *ptr, *path_copy, *free_path;
char *tok;
int ptr_length;
#ifdef TSRM_WIN32
int is_unc;
#endif
no_realpath:
#ifdef TSRM_WIN32
@@ -738,7 +738,12 @@ no_realpath:
}
}
/* Store existent file in realpath cache. */
#ifdef TSRM_WIN32
if (use_cache && !is_unc) {
#else
if (use_cache && (use_realpath == CWD_REALPATH)) {
#endif
realpath_cache_add(path, path_length, state->cwd, state->cwd_length, t TSRMLS_CC);
}
+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
+16 -2
View File
@@ -396,6 +396,7 @@ struct _zend_mm_heap {
size_t free_bitmap;
size_t large_free_bitmap;
size_t block_size;
size_t compact_size;
zend_mm_segment *segments_list;
zend_mm_storage *storage;
size_t real_size;
@@ -1028,6 +1029,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers,
heap->storage = storage;
heap->block_size = block_size;
heap->compact_size = 0;
heap->segments_list = NULL;
zend_mm_init(heap);
# if ZEND_MM_CACHE_STAT
@@ -1078,6 +1080,7 @@ ZEND_API zend_mm_heap *zend_mm_startup(void)
char *mem_type = getenv("ZEND_MM_MEM_TYPE");
char *tmp;
const zend_mm_mem_handlers *handlers;
zend_mm_heap *heap;
if (mem_type == NULL) {
i = 0;
@@ -1109,7 +1112,16 @@ ZEND_API zend_mm_heap *zend_mm_startup(void)
seg_size = ZEND_MM_SEG_SIZE;
}
return zend_mm_startup_ex(handlers, seg_size, ZEND_MM_RESERVE_SIZE, 0, NULL);
heap = zend_mm_startup_ex(handlers, seg_size, ZEND_MM_RESERVE_SIZE, 0, NULL);
if (heap) {
tmp = getenv("ZEND_MM_COMPACT");
if (tmp) {
heap->compact_size = zend_atoi(tmp, 0);
} else {
heap->compact_size = 2 * 1024 * 1024;
}
}
return heap;
}
#if ZEND_DEBUG
@@ -1563,7 +1575,9 @@ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent
#ifdef HAVE_MEM_WIN32
/* FIX for bug #41713 */
/* TODO: add new "compact" handler */
if (storage->handlers->dtor == zend_mm_mem_win32_dtor &&
if (heap->compact_size &&
heap->real_peak > heap->compact_size &&
storage->handlers->dtor == zend_mm_mem_win32_dtor &&
storage->handlers->init == zend_mm_mem_win32_init) {
HeapDestroy((HANDLE)storage->data);
storage->data = (void*)HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
+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="RC2"
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
+2 -4
View File
@@ -19,12 +19,10 @@
int overflow2(int a, int b)
{
if(a < 0 || b < 0) {
php_gd_error("gd warning: one parameter to a memory allocation multiplication is negative, failing operation gracefully\n");
if(a <= 0 || b <= 0) {
php_gd_error("gd warning: one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully\n");
return 1;
}
if(b == 0)
return 0;
if(a > INT_MAX / b) {
php_gd_error("gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n");
return 1;
+3 -5
View File
@@ -2167,9 +2167,9 @@ PHP_FUNCTION(iconv_mime_encode)
PHP_FUNCTION(iconv_mime_decode)
{
char *encoded_str;
int encoded_str_len = 0;
int encoded_str_len;
char *charset;
int charset_len;
int charset_len = 0;
long mode = 0;
smart_str retval = {0};
@@ -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"}"
+3 -2
View File
@@ -345,9 +345,7 @@ PHP_RINIT_FUNCTION(mssql)
MS_SQL_G(min_error_severity) = MS_SQL_G(cfg_min_error_severity);
MS_SQL_G(min_message_severity) = MS_SQL_G(cfg_min_message_severity);
if (MS_SQL_G(connect_timeout) < 1) MS_SQL_G(connect_timeout) = 1;
dbsetlogintime(MS_SQL_G(connect_timeout));
if (MS_SQL_G(timeout) < 0) MS_SQL_G(timeout) = 60;
dbsettime(MS_SQL_G(timeout));
if (MS_SQL_G(max_procs) != -1) {
dbsetmaxprocs((TDS_SHORT)MS_SQL_G(max_procs));
}
@@ -468,6 +466,9 @@ static void php_mssql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
RETURN_FALSE;
}
dbsetlogintime(MS_SQL_G(connect_timeout));
dbsettime(MS_SQL_G(timeout));
/* set a DBLOGIN record */
if ((mssql.login = dblogin()) == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate login record");
+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 */
+12 -9
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;
}
}
@@ -495,6 +494,12 @@ PHP_MINIT_FUNCTION(mysqli)
REGISTER_INI_ENTRIES();
#if MYSQL_VERSION_ID >= 40000
if (mysql_server_init(0, NULL, NULL)) {
return FAILURE;
}
#endif
memcpy(&mysqli_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
mysqli_object_handlers.clone_obj = NULL;
mysqli_object_handlers.read_property = mysqli_read_property;
@@ -632,7 +637,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);
@@ -652,10 +657,6 @@ PHP_MINIT_FUNCTION(mysqli)
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_ALL", MYSQLI_REPORT_ALL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_OFF", 0, CONST_CS | CONST_PERSISTENT);
if (mysql_server_init(0, NULL, NULL)) {
return FAILURE;
}
return SUCCESS;
}
/* }}} */
@@ -664,6 +665,7 @@ PHP_MINIT_FUNCTION(mysqli)
*/
PHP_MSHUTDOWN_FUNCTION(mysqli)
{
#if MYSQL_VERSION_ID >= 40000
#ifdef PHP_WIN32
unsigned long client_ver = mysql_get_client_version();
/* Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows */
@@ -672,6 +674,7 @@ PHP_MSHUTDOWN_FUNCTION(mysqli)
}
#else
mysql_server_end();
#endif
#endif
zend_hash_destroy(&mysqli_driver_properties);
@@ -690,7 +693,7 @@ PHP_MSHUTDOWN_FUNCTION(mysqli)
*/
PHP_RINIT_FUNCTION(mysqli)
{
#ifdef ZTS
#ifdef ZTS && MYSQL_VERSION_ID >= 40000
if (mysql_thread_init()) {
return FAILURE;
}
@@ -706,7 +709,7 @@ PHP_RINIT_FUNCTION(mysqli)
*/
PHP_RSHUTDOWN_FUNCTION(mysqli)
{
#ifdef ZTS
#ifdef ZTS && MYSQL_VERSION_ID >= 40000
mysql_thread_end();
#endif
if (MyG(error_msg)) {
+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;\
+1 -1
View File
@@ -18,7 +18,7 @@ local infile handler
mysqli_real_connect($link, $host, $user, $passwd, "test");
/* create temporary file */
$filename = dirname(__FILE__) . "061.csv";
$filename = dirname(__FILE__) . "/061.csv";
$fp = fopen($filename, "w");
fwrite($fp, "foo;bar");
fclose($fp);
+3
View File
@@ -46,6 +46,9 @@
#include <openssl/ssl.h>
#include <openssl/pkcs12.h>
/* Common */
#include <time.h>
#define DEFAULT_KEY_LENGTH 512
#define MIN_KEY_LENGTH 384
+238 -130
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 0.11.0 on Tue Jun 5 18:45:24 2007 */
/* Generated by re2c 0.11.0 on Mon Oct 29 18:36:37 2007 */
#line 1 "ext/pdo/pdo_sql_parser.re"
/*
+----------------------------------------------------------------------+
@@ -50,142 +50,250 @@ static int scan(Scanner *s)
#line 55 "ext/pdo/pdo_sql_parser.re"
{
static unsigned char yybm[] = {
192, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 64, 200, 200, 200, 200, 128,
200, 200, 200, 200, 200, 200, 200, 200,
232, 232, 232, 232, 232, 232, 232, 232,
232, 232, 208, 200, 200, 200, 200, 208,
200, 232, 232, 232, 232, 232, 232, 232,
232, 232, 232, 232, 232, 232, 232, 232,
232, 232, 232, 232, 232, 232, 232, 232,
232, 232, 232, 200, 200, 200, 200, 232,
200, 232, 232, 232, 232, 232, 232, 232,
232, 232, 232, 232, 232, 232, 232, 232,
232, 232, 232, 232, 232, 232, 232, 232,
232, 232, 232, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200,
};
#line 55 "ext/pdo/pdo_sql_parser.c"
{
YYCTYPE yych;
#line 90 "ext/pdo/pdo_sql_parser.c"
{
YYCTYPE yych;
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
if(yybm[0+yych] & 8) {
goto yy8;
}
if(yych <= 0x00) goto yy11;
if(yych <= '&') goto yy2;
if(yych <= '\'') goto yy4;
if(yych <= '>') goto yy5;
goto yy6;
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych) {
case 0x00: goto yy11;
case '"': goto yy2;
case '\'': goto yy4;
case ':': goto yy5;
case '?': goto yy6;
default: goto yy8;
}
yy2:
yych = *++YYCURSOR;
goto yy24;
yych = *++YYCURSOR;
goto yy24;
yy3:
#line 63 "ext/pdo/pdo_sql_parser.re"
{ SKIP_ONE(PDO_PARSER_TEXT); }
#line 110 "ext/pdo/pdo_sql_parser.c"
{ SKIP_ONE(PDO_PARSER_TEXT); }
#line 75 "ext/pdo/pdo_sql_parser.c"
yy4:
yych = *++YYCURSOR;
goto yy20;
yych = *++YYCURSOR;
goto yy20;
yy5:
yych = *++YYCURSOR;
if(yybm[0+yych] & 32) {
goto yy16;
}
if(yych == ':') goto yy13;
if(yych == '?') goto yy13;
goto yy3;
yy6:
++YYCURSOR;
if(yybm[0+(yych = *YYCURSOR)] & 16) {
goto yy13;
}
#line 62 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_BIND_POS); }
#line 129 "ext/pdo/pdo_sql_parser.c"
yy8:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if(yybm[0+yych] & 8) {
goto yy8;
}
#line 64 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 139 "ext/pdo/pdo_sql_parser.c"
yy11:
++YYCURSOR;
#line 65 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_EOI); }
#line 144 "ext/pdo/pdo_sql_parser.c"
yy13:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if(yybm[0+yych] & 16) {
goto yy13;
}
#line 60 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 154 "ext/pdo/pdo_sql_parser.c"
yy16:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if(yybm[0+yych] & 32) {
goto yy16;
}
#line 61 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_BIND); }
#line 164 "ext/pdo/pdo_sql_parser.c"
yy19:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy20:
if(yybm[0+yych] & 64) {
goto yy19;
}
++YYCURSOR;
#line 59 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 176 "ext/pdo/pdo_sql_parser.c"
yy23:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy24:
if(yybm[0+yych] & 128) {
goto yy23;
}
++YYCURSOR;
#line 58 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 188 "ext/pdo/pdo_sql_parser.c"
yych = *++YYCURSOR;
switch(yych) {
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
case '_':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z': goto yy16;
case ':':
case '?': goto yy13;
default: goto yy3;
}
yy6:
++YYCURSOR;
switch((yych = *YYCURSOR)) {
case ':':
case '?': goto yy13;
default: goto yy7;
}
yy7:
#line 62 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_BIND_POS); }
#line 160 "ext/pdo/pdo_sql_parser.c"
yy8:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych) {
case 0x00:
case '"':
case '\'':
case ':':
case '?': goto yy10;
default: goto yy8;
}
yy10:
#line 64 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 176 "ext/pdo/pdo_sql_parser.c"
yy11:
++YYCURSOR;
#line 65 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_EOI); }
#line 181 "ext/pdo/pdo_sql_parser.c"
yy13:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych) {
case ':':
case '?': goto yy13;
default: goto yy15;
}
yy15:
#line 60 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 194 "ext/pdo/pdo_sql_parser.c"
yy16:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych) {
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
case '_':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z': goto yy16;
default: goto yy18;
}
yy18:
#line 61 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_BIND); }
#line 269 "ext/pdo/pdo_sql_parser.c"
yy19:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy20:
switch(yych) {
case '\'': goto yy21;
default: goto yy19;
}
yy21:
++YYCURSOR;
#line 59 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 283 "ext/pdo/pdo_sql_parser.c"
yy23:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy24:
switch(yych) {
case '"': goto yy25;
default: goto yy23;
}
yy25:
++YYCURSOR;
#line 58 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
#line 297 "ext/pdo/pdo_sql_parser.c"
}
#line 66 "ext/pdo/pdo_sql_parser.re"
+1 -1
View File
@@ -46,7 +46,7 @@ static int scan(Scanner *s)
s->tok = cursor;
/*!re2c
BINDCHR = [:][a-zA-Z0-9_]+;
BINDCHR = [:][a-zA-Z0-9_-]+;
QUESTION = [?];
SPECIALS = [:?"'];
MULTICHAR = [:?];
+10 -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;
@@ -1546,10 +1546,16 @@ static PHP_METHOD(PDOStatement, fetchAll)
}
}
if ((how & ~PDO_FETCH_FLAGS) == PDO_FETCH_USE_DEFAULT) {
how |= stmt->default_fetch_type & ~PDO_FETCH_FLAGS;
}
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 +1571,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 +1922,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"
}
+31
View File
@@ -0,0 +1,31 @@
--TEST--
PDO Common: Bug #43130 (Bound parameters cannot have - in their name)
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded('pdo')) die('skip');
$dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
if (!strncasecmp(getenv('PDOTEST_DSN'), 'sqlite', strlen('sqlite'))) die('skip not relevant for sqlite 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."')");
}
$stmt = $db->prepare("SELECT a FROM test WHERE b=:id-value");
$stmt->bindParam(':id-value', $id);
$id = '1';
$stmt->execute();
var_dump($stmt->fetch(PDO::FETCH_COLUMN));
?>
--EXPECT--
string(5) "test1"
+34
View File
@@ -0,0 +1,34 @@
--TEST--
PDO Common: Bug #43139 (PDO ignore ATTR_DEFAULT_FETCH_MODE in some cases with fetchAll())
--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->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
var_dump($db->query('select 0 as abc, 1 as xyz, 2 as def')->fetchAll(PDO::FETCH_GROUP));
?>
--EXPECT--
array(1) {
[0]=>
array(1) {
[0]=>
array(2) {
["xyz"]=>
string(1) "1"
["def"]=>
string(1) "2"
}
}
}
+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===
+11 -7
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!");
@@ -3405,7 +3405,7 @@ ZEND_METHOD(reflection_class, isInstance)
Returns an instance of this class */
ZEND_METHOD(reflection_class, newInstance)
{
zval *retval_ptr;
zval *retval_ptr = NULL;
reflection_object *intern;
zend_class_entry *ce;
int argc = ZEND_NUM_ARGS();
@@ -3449,7 +3449,9 @@ ZEND_METHOD(reflection_class, newInstance)
if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {
efree(params);
zval_ptr_dtor(&retval_ptr);
if (retval_ptr) {
zval_ptr_dtor(&retval_ptr);
}
zend_error(E_WARNING, "Invocation of %s's constructor failed", ce->name);
RETURN_NULL();
}
@@ -3469,7 +3471,7 @@ ZEND_METHOD(reflection_class, newInstance)
Returns an instance of this class */
ZEND_METHOD(reflection_class, newInstanceArgs)
{
zval *retval_ptr;
zval *retval_ptr = NULL;
reflection_object *intern;
zend_class_entry *ce;
int argc = 0;
@@ -3524,7 +3526,9 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
if (params) {
efree(params);
}
zval_ptr_dtor(&retval_ptr);
if (retval_ptr) {
zval_ptr_dtor(&retval_ptr);
}
zend_error(E_WARNING, "Invocation of %s's constructor failed", ce->name);
RETURN_NULL();
}
+34
View File
@@ -0,0 +1,34 @@
--TEST--
Bug #42976 (Crash when constructor for newInstance() or newInstanceArgs() fails)
--FILE--
<?php
Class C {
function __construct(&$x) {
$x = "x.changed";
}
}
$x = "x.original";
new C($x); // OK
var_dump($x);
$rc = new ReflectionClass('C');
$x = "x.original";
$rc->newInstance($x); // causes crash
var_dump($x);
$x = "x.original";
$rc->newInstanceArgs(array($x)); // causes crash
var_dump($x);
echo "Done\n";
?>
--EXPECTF--
string(9) "x.changed"
Warning: Invocation of C's constructor failed in %s/bug42976.php on line %d
string(10) "x.original"
Warning: Invocation of C's constructor failed in %s/bug42976.php on line %d
string(10) "x.original"
Done
+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] != '/') {
+52 -4
View File
@@ -1872,8 +1872,10 @@ PHP_METHOD(SoapServer, handle)
INIT_ZVAL(result);
ZVAL_STRINGL(&nm_ob_gzhandler, "ob_gzhandler", sizeof("ob_gzhandler") - 1, 0);
INIT_PZVAL(&str);
ZVAL_STRINGL(&str, (char*)buf, size, 0);
params[0] = &str;
INIT_PZVAL(&mode);
ZVAL_LONG(&mode, PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END);
params[1] = &mode;
if (call_user_function(CG(function_table), NULL, &nm_ob_gzhandler, &result, 2, params TSRMLS_CC) != FAILURE &&
@@ -2011,17 +2013,47 @@ static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeade
our fault code with their own handling... Figure this out later
*/
sapi_add_header("HTTP/1.1 500 Internal Service Error", sizeof("HTTP/1.1 500 Internal Service Error")-1, 1);
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
sapi_add_header(cont_len, strlen(cont_len), 1);
if (soap_version == SOAP_1_2) {
sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);
} else {
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
}
php_write(buf, size TSRMLS_CC);
if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0) &&
zend_hash_exists(EG(function_table), "ob_gzhandler", sizeof("ob_gzhandler"))) {
zval nm_ob_gzhandler;
zval str;
zval mode;
zval result;
zval *params[2];
INIT_ZVAL(result);
ZVAL_STRINGL(&nm_ob_gzhandler, "ob_gzhandler", sizeof("ob_gzhandler") - 1, 0);
INIT_PZVAL(&str);
ZVAL_STRINGL(&str, (char*)buf, size, 0);
params[0] = &str;
INIT_PZVAL(&mode);
ZVAL_LONG(&mode, PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END);
params[1] = &mode;
if (call_user_function(CG(function_table), NULL, &nm_ob_gzhandler, &result, 2, params TSRMLS_CC) != FAILURE &&
Z_TYPE(result) == IS_STRING &&
zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == SUCCESS) {
xmlFree(buf);
buf = NULL;
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", Z_STRLEN(result));
sapi_add_header(cont_len, strlen(cont_len), 1);
php_write(Z_STRVAL(result), Z_STRLEN(result) TSRMLS_CC);
}
zval_dtor(&result);
}
if (buf) {
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
sapi_add_header(cont_len, strlen(cont_len), 1);
php_write(buf, size TSRMLS_CC);
xmlFree(buf);
}
xmlFreeDoc(doc_return);
xmlFree(buf);
zend_clear_exception(TSRMLS_C);
}
@@ -2041,11 +2073,15 @@ static void soap_error_handler(int error_num, const char *error_filename, const
{
zend_bool _old_in_compilation, _old_in_execution;
zend_execute_data *_old_current_execute_data;
int _old_http_response_code;
char *_old_http_status_line;
TSRMLS_FETCH();
_old_in_compilation = CG(in_compilation);
_old_in_execution = EG(in_execution);
_old_current_execute_data = EG(current_execute_data);
_old_http_response_code = SG(sapi_headers).http_response_code;
_old_http_status_line = SG(sapi_headers).http_status_line;
if (!SOAP_GLOBAL(use_soap_error_handler)) {
call_old_error_handler(error_num, error_filename, error_lineno, format, args);
@@ -2103,12 +2139,18 @@ static void soap_error_handler(int error_num, const char *error_filename, const
old_objects = EG(objects_store).object_buckets;
EG(objects_store).object_buckets = NULL;
PG(display_errors) = 0;
SG(sapi_headers).http_status_line = NULL;
zend_try {
call_old_error_handler(error_num, error_filename, error_lineno, format, args);
} zend_catch {
CG(in_compilation) = _old_in_compilation;
EG(in_execution) = _old_in_execution;
EG(current_execute_data) = _old_current_execute_data;
if (SG(sapi_headers).http_status_line) {
efree(SG(sapi_headers).http_status_line);
}
SG(sapi_headers).http_status_line = _old_http_status_line;
SG(sapi_headers).http_response_code = _old_http_response_code;
} zend_end_try();
EG(objects_store).object_buckets = old_objects;
PG(display_errors) = old;
@@ -2181,12 +2223,18 @@ static void soap_error_handler(int error_num, const char *error_filename, const
}
PG(display_errors) = 0;
SG(sapi_headers).http_status_line = NULL;
zend_try {
call_old_error_handler(error_num, error_filename, error_lineno, format, args);
} zend_catch {
CG(in_compilation) = _old_in_compilation;
EG(in_execution) = _old_in_execution;
EG(current_execute_data) = _old_current_execute_data;
if (SG(sapi_headers).http_status_line) {
efree(SG(sapi_headers).http_status_line);
}
SG(sapi_headers).http_status_line = _old_http_status_line;
SG(sapi_headers).http_response_code = _old_http_response_code;
} zend_end_try();
PG(display_errors) = old;
+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
+10 -8
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; \
@@ -964,7 +964,7 @@ PHP_FUNCTION(min)
zval **result;
if (argc<=0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Atleast one value should be passed");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "At least one value should be passed");
RETURN_NULL();
}
set_compare_func(SORT_REGULAR TSRMLS_CC);
@@ -977,7 +977,7 @@ PHP_FUNCTION(min)
if (zend_hash_minmax(Z_ARRVAL_PP(arr), array_data_compare, 0, (void **) &result TSRMLS_CC) == SUCCESS) {
RETVAL_ZVAL(*result, 1, 0);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain atleast one element");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain at least one element");
RETURN_FALSE;
}
} else {
@@ -1014,7 +1014,7 @@ PHP_FUNCTION(max)
zval **result;
if (argc<=0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Atleast one value should be passed");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "At least one value should be passed");
RETURN_NULL();
}
set_compare_func(SORT_REGULAR TSRMLS_CC);
@@ -1027,7 +1027,7 @@ PHP_FUNCTION(max)
if (zend_hash_minmax(Z_ARRVAL_PP(arr), array_data_compare, 1, (void **) &result TSRMLS_CC) == SUCCESS) {
RETVAL_ZVAL(*result, 1, 0);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain atleast one element");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain at least one element");
RETURN_FALSE;
}
} else {
@@ -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 {
+22 -3
View File
@@ -50,6 +50,11 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
#include <time.h>
#include <stdio.h>
#ifndef PHP_WIN32
#include <sys/types.h>
#include <sys/stat.h>
#endif
#ifdef NETWARE
#include <netinet/in.h>
#endif
@@ -4496,7 +4501,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 +4815,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;
}
@@ -6075,6 +6080,10 @@ PHP_FUNCTION(move_uploaded_file)
zval **path, **new_path;
zend_bool successful = 0;
#ifndef PHP_WIN32
int oldmask; int ret;
#endif
if (!SG(rfc1867_uploaded_files)) {
RETURN_FALSE;
}
@@ -6100,6 +6109,16 @@ PHP_FUNCTION(move_uploaded_file)
VCWD_UNLINK(Z_STRVAL_PP(new_path));
if (VCWD_RENAME(Z_STRVAL_PP(path), Z_STRVAL_PP(new_path)) == 0) {
successful = 1;
#ifndef PHP_WIN32
oldmask = umask(077);
umask(oldmask);
ret = VCWD_CHMOD(Z_STRVAL_PP(new_path), 0666 & ~oldmask);
if (ret == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
}
#endif
} else if (php_copy_file_ex(Z_STRVAL_PP(path), Z_STRVAL_PP(new_path), STREAM_DISABLE_OPEN_BASEDIR TSRMLS_CC) == SUCCESS) {
VCWD_UNLINK(Z_STRVAL_PP(path));
successful = 1;
@@ -6273,7 +6292,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;
}
+14 -7
View File
@@ -698,14 +698,10 @@ PHP_FUNCTION(touch)
/* }}} */
#endif
/* {{{ proto void clearstatcache(void)
Clear file stat cache */
PHP_FUNCTION(clearstatcache)
/* {{{ php_clear_stat_cache()
*/
PHPAPI void php_clear_stat_cache(TSRMLS_D)
{
if (ZEND_NUM_ARGS()) {
WRONG_PARAM_COUNT;
}
if (BG(CurrentStatFile)) {
efree(BG(CurrentStatFile));
BG(CurrentStatFile) = NULL;
@@ -718,6 +714,17 @@ PHP_FUNCTION(clearstatcache)
}
/* }}} */
/* {{{ proto void clearstatcache(void)
Clear file stat cache */
PHP_FUNCTION(clearstatcache)
{
if (ZEND_NUM_ARGS()) {
WRONG_PARAM_COUNT;
}
php_clear_stat_cache(TSRMLS_C);
}
/* }}} */
#define IS_LINK_OPERATION(__t) ((__t) == FS_TYPE || (__t) == FS_IS_LINK || (__t) == FS_LSTAT)
#define IS_EXISTS_CHECK(__t) ((__t) == FS_EXISTS || (__t) == FS_IS_W || (__t) == FS_IS_R || (__t) == FS_IS_X || (__t) == FS_IS_FILE || (__t) == FS_IS_DIR || (__t) == FS_IS_LINK)
#define IS_ABLE_CHECK(__t) ((__t) == FS_IS_R || (__t) == FS_IS_W || (__t) == FS_IS_X)
+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
View File
@@ -87,6 +87,7 @@ typedef unsigned int php_stat_len;
typedef int php_stat_len;
#endif
PHPAPI void php_clear_stat_cache(TSRMLS_D);
PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int type, zval *return_value TSRMLS_DC);
/* Switches for various filestat functions: */
+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,97 @@
--TEST--
Test array_fill() function : basic functionality
--FILE--
<?php
/* Prototype : array array_fill(int $start_key, int $num, mixed $val)
* Description: Create an array containing num elements starting with index start_key each initialized to val
* Source code: ext/standard/array.c
*/
echo "*** Testing array_fill() : basic functionality ***\n";
// calling the array_fill with all possible valid values for 'val' argument
$start_key = 0 ;
$num = 2;
$heredoc = <<<HERE_DOC
Hello
HERE_DOC;
// array of possible valid values for 'val' arugment
$values = array (
/* 1 */ NULL,
0,
1,
/* 4 */ 1.5,
'hi',
"hi",
/* 7 */ $heredoc
);
$counter = 1;
for($i = 0; $i < count($values); $i ++)
{
echo "-- Iteration $counter --\n";
$val = $values[$i];
var_dump( array_fill($start_key, $num, $val) );
$counter++;
}
echo "Done";
?>
--EXPECTF--
*** Testing array_fill() : basic functionality ***
-- Iteration 1 --
array(2) {
[0]=>
NULL
[1]=>
NULL
}
-- Iteration 2 --
array(2) {
[0]=>
int(0)
[1]=>
int(0)
}
-- Iteration 3 --
array(2) {
[0]=>
int(1)
[1]=>
int(1)
}
-- Iteration 4 --
array(2) {
[0]=>
float(1.5)
[1]=>
float(1.5)
}
-- Iteration 5 --
array(2) {
[0]=>
string(2) "hi"
[1]=>
string(2) "hi"
}
-- Iteration 6 --
array(2) {
[0]=>
string(2) "hi"
[1]=>
string(2) "hi"
}
-- Iteration 7 --
array(2) {
[0]=>
string(5) "Hello"
[1]=>
string(5) "Hello"
}
Done
@@ -0,0 +1,61 @@
--TEST--
Test array_fill() function : error conditions
--FILE--
<?php
/* Prototype : array array_fill(int $start_key, int $num, mixed $val)
* Description: Create an array containing num elements starting with index start_key each initialized to val
* Source code: ext/standard/array.c
*/
echo "*** Testing array_fill() : error conditions ***\n";
// Zero arguments
echo "-- Testing array_fill() function with Zero arguments --\n";
var_dump( array_fill() );
// More than expected number of arguments
echo "-- Testing array_fill() function with more than expected no. of arguments --\n";
$start_key = 0;
$num = 2;
$val = 1;
$extra_arg = 10;
var_dump( array_fill($start_key, $num,$val, $extra_arg) );
// Less than the expected number of arguments
echo "-- Testing array_fill() function with less than expected no. of arguments --\n";
$start_key = 0;
$num = 2;
var_dump( array_fill($start_key, $num) );
//calling array_fill with negative values for 'num' parameter
$num = -1;
var_dump( array_fill($start_key, $num, $val) );
//callin array_fill with 'num' equal to zero value
$num = 0;
var_dump( array_fill($start_key, $num, $val) );
echo "Done";
?>
--EXPECTF--
*** Testing array_fill() : error conditions ***
-- Testing array_fill() function with Zero arguments --
Warning: Wrong parameter count for array_fill() in %s on line %d
NULL
-- Testing array_fill() function with more than expected no. of arguments --
Warning: Wrong parameter count for array_fill() in %s on line %d
NULL
-- Testing array_fill() function with less than expected no. of arguments --
Warning: Wrong parameter count for array_fill() in %s on line %d
NULL
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
Done
@@ -0,0 +1,432 @@
--TEST--
Test array_fill() function : usage variations - various object values for 'val' argument
--FILE--
<?php
/* Prototype : array array_fill(int $start_key, int $num, mixed $val)
* Description: Create an array containing num elements starting with index start_key each initialized to val
* Source code: ext/standard/array.c
*/
/*
* testing array_fill() by passing various object values for 'val' argument
*/
echo "*** Testing array_fill() : usage variations ***\n";
// Initialise function arguments not being substituted
$start_key = 0;
$num = 2;
// class without a member
class Test
{
}
//class with public, static, constant members and consturctor to initialize the public member
class Test1
{
const test1_constant = "test1";
public static $test1_static = 0;
public $member1;
var $var1 = 30;
var $var2;
function __construct($value1, $value2)
{
$this->member1 = $value1;
$this->var2 = $value2;
}
}
// child class which inherits parent class test1
class Child_test1 extends Test1
{
public $member2;
function __construct($value1, $value2, $value3)
{
parent::__construct($value1, $value2);
$this->member2 = $value3;
}
}
//class with private, static, constant members and constructor to initialize the private member
class Test2
{
const test2_constant = "test2";
public static $test2_static = 0;
private $member1;
var $var1 = 30;
var $var2;
function __construct($value1,$value2)
{
$this->member1 = $value1;
$this->var2 = $value2;
}
}
// child class which inherits parent class test2
class Child_test2 extends Test2
{
private $member1;
function __construct($value1, $value2, $value3)
{
parent::__construct($value1, $value2);
$this->member1 = $value3;
}
}
// class with protected, static, constant members and consturctor to initialize the protected member
class Test3
{
const test3_constant = "test3";
public static $test3_static = 0;
protected $member1;
var $var1 = 30;
var $var2;
function __construct($value1, $value2)
{
$this->member1 = $value1;
$this->var2 = $value2;
}
}
// child class which inherits parent class test3
class Child_test3 extends Test3
{
protected $member1;
function __construct($value1, $value2, $value3)
{
parent::__construct($value1, $value2);
$this->member1 = $value3;
}
}
// class with public, private, protected members, static, constant members and constructor to initialize all the members
class Test4
{
const test4_constant = "test4";
public static $test4_static = 0;
public $member1;
private $member2;
protected $member3;
function __construct($value1, $value2, $value3)
{
$this->member1 = $value1;
$this->member2 = $value2;
$this->member3 = $value3;
}
}
// child class which inherits parent class test4
class Child_test4 extends Test4
{
var $var1;
function __construct($value1, $value2, $value3, $value4)
{
parent::__construct($value1, $value2, $value3);
$this->var1 = $value4;
}
}
// abstract class with public, private, protected members
abstract class AbstractClass
{
public $member1;
private $member2;
protected $member3;
var $var1 = 30;
abstract protected function display();
}
// implement abstract 'AbstractClass' class
class ConcreteClass1 extends AbstractClass
{
protected function display()
{
echo "class name is ConcreteClass1 \n";
}
}
// declarationn of the interface 'iTemplate'
interface iTemplate
{
public function display();
}
// implement the interface 'iTemplate'
class Template1 implements iTemplate
{
public function display()
{
echo "class name is Template1\n";
}
}
//array of object values for 'val' argument
$objects = array(
/* 1 */ new Test(),
new Test1(100 , 101),
new Child_test1(100 , 101 , 102),
new Test2(100 , 101),
/* 5 */ new Child_test2(100 , 101 , 102),
new Test3(100 , 101),
new Child_test3(100 , 101 , 102),
new Test4( 100 , 101 , 102),
new Child_test4(100 , 101 , 102 , 103),
new ConcreteClass1(),
/* 11 */ new Template1()
);
// loop through each element of the array for 'val' argument
// check the working of array_fill()
echo "--- Testing array_fill() with different object values for 'val' argument ---\n";
$counter = 1;
for($index = 0; $index < count($objects); $index ++)
{
echo "-- Iteration $counter --\n";
$val = $objects[$index];
var_dump( array_fill($start_key, $num, $val) );
$counter++;
}
echo "Done";
?>
--EXPECTF--
*** Testing array_fill() : usage variations ***
--- Testing array_fill() with different object values for 'val' argument ---
-- Iteration 1 --
array(2) {
[0]=>
object(Test)#%d (0) {
}
[1]=>
object(Test)#%d (0) {
}
}
-- Iteration 2 --
array(2) {
[0]=>
object(Test1)#%d (3) {
["member1"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
[1]=>
object(Test1)#%d (3) {
["member1"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
}
-- Iteration 3 --
array(2) {
[0]=>
object(Child_test1)#%d (4) {
["member2"]=>
int(102)
["member1"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
[1]=>
object(Child_test1)#%d (4) {
["member2"]=>
int(102)
["member1"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
}
-- Iteration 4 --
array(2) {
[0]=>
object(Test2)#%d (3) {
["member1:private"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
[1]=>
object(Test2)#%d (3) {
["member1:private"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
}
-- Iteration 5 --
array(2) {
[0]=>
object(Child_test2)#%d (4) {
["member1:private"]=>
int(102)
["member1:private"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
[1]=>
object(Child_test2)#%d (4) {
["member1:private"]=>
int(102)
["member1:private"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
}
-- Iteration 6 --
array(2) {
[0]=>
object(Test3)#%d (3) {
["member1:protected"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
[1]=>
object(Test3)#%d (3) {
["member1:protected"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
}
-- Iteration 7 --
array(2) {
[0]=>
object(Child_test3)#%d (3) {
["member1:protected"]=>
int(102)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
[1]=>
object(Child_test3)#%d (3) {
["member1:protected"]=>
int(102)
["var1"]=>
int(30)
["var2"]=>
int(101)
}
}
-- Iteration 8 --
array(2) {
[0]=>
object(Test4)#%d (3) {
["member1"]=>
int(100)
["member2:private"]=>
int(101)
["member3:protected"]=>
int(102)
}
[1]=>
object(Test4)#%d (3) {
["member1"]=>
int(100)
["member2:private"]=>
int(101)
["member3:protected"]=>
int(102)
}
}
-- Iteration 9 --
array(2) {
[0]=>
object(Child_test4)#%d (4) {
["var1"]=>
int(103)
["member1"]=>
int(100)
["member2:private"]=>
int(101)
["member3:protected"]=>
int(102)
}
[1]=>
object(Child_test4)#%d (4) {
["var1"]=>
int(103)
["member1"]=>
int(100)
["member2:private"]=>
int(101)
["member3:protected"]=>
int(102)
}
}
-- Iteration 10 --
array(2) {
[0]=>
object(ConcreteClass1)#%d (4) {
["member1"]=>
NULL
["member2:private"]=>
NULL
["member3:protected"]=>
NULL
["var1"]=>
int(30)
}
[1]=>
object(ConcreteClass1)#%d (4) {
["member1"]=>
NULL
["member2:private"]=>
NULL
["member3:protected"]=>
NULL
["var1"]=>
int(30)
}
}
-- Iteration 11 --
array(2) {
[0]=>
object(Template1)#%d (0) {
}
[1]=>
object(Template1)#%d (0) {
}
}
Done
@@ -0,0 +1,255 @@
--TEST--
Test array_fill() function : usage variations - unexpected values for 'start_key' argument(Bug#43017)
--FILE--
<?php
/* Prototype : array array_fill(int $start_key, int $num, mixed $val)
* Description: Create an array containing num elements starting with index start_key each initialized to val
* Source code: ext/standard/array.c
*/
/*
* testing array_fill() by passing different unexpected value for 'start_key' argument
*/
echo "*** Testing array_fill() : usage variations ***\n";
// Initialise function arguments not being substituted
$num = 2;
$val = 100;
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//get a resource variable
$fp = fopen(__FILE__, "r");
//define a class
class test
{
var $t = 10;
function __toString()
{
return "testObject";
}
}
//array of different values for 'start_key' argument
$values = array(
// float values
/* 1 */ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// array values
/* 6 */ array(),
array(0),
array(1),
array(1, 2),
array('color' => 'red', 'item' => 'pen'),
// null values
/* 11 */ NULL,
null,
// boolean values
/* 13 */ true,
false,
TRUE,
FALSE,
// empty string
/* 17 */ "",
'',
// string values
/* 19 */ "string",
'string',
// objects
/* 21 */ new test(),
// undefined variable
@$undefined_var,
// unset variable
@$unset_var,
// resource variable
/* 24 */ $fp
);
// loop through each element of the array for start_key
// check the working of array_fill()
echo "--- Testing array_fill() with different values for 'start_key' arg ---\n";
$counter = 1;
for($index = 0; $index < count($values); $index ++)
{
echo "-- Iteration $counter --\n";
$start_key = $values[$index];
var_dump( array_fill($start_key,$num,$val) );
$counter ++;
}
// close the resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_fill() : usage variations ***
--- Testing array_fill() with different values for 'start_key' arg ---
-- Iteration 1 --
array(2) {
[10]=>
int(100)
[11]=>
int(100)
}
-- Iteration 2 --
array(2) {
[-10]=>
int(100)
[0]=>
int(100)
}
-- Iteration 3 --
array(2) {
[-1097262584]=>
int(100)
[0]=>
int(100)
}
-- Iteration 4 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 5 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 6 --
Warning: array_fill(): Wrong data type for start key in %s on line %d
bool(false)
-- Iteration 7 --
Warning: array_fill(): Wrong data type for start key in %s on line %d
bool(false)
-- Iteration 8 --
Warning: array_fill(): Wrong data type for start key in %s on line %d
bool(false)
-- Iteration 9 --
Warning: array_fill(): Wrong data type for start key in %s on line %d
bool(false)
-- Iteration 10 --
Warning: array_fill(): Wrong data type for start key in %s on line %d
bool(false)
-- Iteration 11 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 12 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 13 --
array(2) {
[1]=>
int(100)
[2]=>
int(100)
}
-- Iteration 14 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 15 --
array(2) {
[1]=>
int(100)
[2]=>
int(100)
}
-- Iteration 16 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 17 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 18 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 19 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 20 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 21 --
Warning: array_fill(): Wrong data type for start key in %s on line %d
bool(false)
-- Iteration 22 --
Warning: array_fill(): Wrong data type for start key in %s on line %d
bool(false)
-- Iteration 23 --
Warning: array_fill(): Wrong data type for start key in %s on line %d
bool(false)
-- Iteration 24 --
Warning: array_fill(): Wrong data type for start key in %s on line %d
bool(false)
Done
@@ -0,0 +1,213 @@
--TEST--
Test array_fill() function : usage variations - unexpected values for 'num' argument
--FILE--
<?php
/* Prototype : array array_fill(int $start_key, int $num, mixed $val)
* Description: Create an array containing num elements starting with index start_key each initialized to val
* Source code: ext/standard/array.c
*/
/*
* testing array_fill() by passing different unexpected values for 'num' argument
*/
echo "*** Testing array_fill() : usage variations ***\n";
// Initialise function arguments not being substituted (if any)
$start_key = 0;
$val = 100;
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//define a class
class test
{
var $t = 10;
function __toString()
{
return "testObject";
}
}
//array of different values for 'num' argument
$values = array(
// float values
/* 1 */ 2.5,
-2.5,
0.5e1,
0.5E-1,
.5,
// array values
/* 6 */ array(),
array(0),
array(1),
array(1, 2),
array('color' => 'red', 'item' => 'pen'),
// null values
/* 11 */ NULL,
null,
// boolean values
/* 13 */ true,
false,
TRUE,
FALSE,
// empty string
/* 17 */ "",
'',
// string values
/* 19 */ "string",
'string',
// objects
/* 21 */ new test(),
// undefined variable
@$undefined_var,
// unset variable
/* 23 */ @$unset_var,
);
// loop through each element of the array for num
// check the working of array_fill
echo "--- Testing array_fill() with different values for 'num' arg ---\n";
$counter = 1;
for($index = 0; $index < count($values); $index ++)
{
echo "-- Iteration $counter --\n";
$num = $values[$index];
var_dump( array_fill($start_key, $num, $val) );
$counter ++;
}
echo "Done";
?>
--EXPECTF--
*** Testing array_fill() : usage variations ***
--- Testing array_fill() with different values for 'num' arg ---
-- Iteration 1 --
array(2) {
[0]=>
int(100)
[1]=>
int(100)
}
-- Iteration 2 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 3 --
array(5) {
[0]=>
int(100)
[1]=>
int(100)
[2]=>
int(100)
[3]=>
int(100)
[4]=>
int(100)
}
-- Iteration 4 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 5 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 6 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 7 --
array(1) {
[0]=>
int(100)
}
-- Iteration 8 --
array(1) {
[0]=>
int(100)
}
-- Iteration 9 --
array(1) {
[0]=>
int(100)
}
-- Iteration 10 --
array(1) {
[0]=>
int(100)
}
-- Iteration 11 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 12 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 13 --
array(1) {
[0]=>
int(100)
}
-- Iteration 14 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 15 --
array(1) {
[0]=>
int(100)
}
-- Iteration 16 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 17 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 18 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 19 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 20 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 21 --
Notice: Object of class test could not be converted to int in %s on line %d
array(1) {
[0]=>
int(100)
}
-- Iteration 22 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
-- Iteration 23 --
Warning: array_fill(): Number of elements must be positive in %s on line %d
bool(false)
Done
@@ -0,0 +1,110 @@
--TEST--
Test array_fill() function : usage variations - unexpected values for 'val' argument
--FILE--
<?php
/* Prototype : array array_fill(int $start_key, int $num, mixed $val)
* Description: Create an array containing num elements starting with index start_key each initialized to val
* Source code: ext/standard/array.c
*/
/*
* testing array_fill() by passing different unexpected values for 'val' argument
*/
echo "*** Testing array_fill() : usage variations ***\n";
// Initialise function arguments not being substituted
$start_key = 0;
$num = 2;
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// define a class
class test
{
var $t = 10;
function __toString()
{
return "testObject";
}
}
//array of different values for 'val' argument
$values = array(
// empty string
/* 1 */ "",
'',
// objects
/* 3 */ new test(),
// undefined variable
@$undefined_var,
// unset variable
/* 5 */ @$unset_var,
);
// loop through each element of the array for 'val' argument
// check the working of array_fill()
echo "--- Testing array_fill() with different values for 'val' argument ---\n";
$counter = 1;
for($index = 0; $index < count($values); $index ++)
{
echo "-- Iteration $counter --\n";
$val = $values[$index];
var_dump( array_fill($start_key, $num, $val) );
$counter++;
}
echo"Done";
?>
--EXPECTF--
*** Testing array_fill() : usage variations ***
--- Testing array_fill() with different values for 'val' argument ---
-- Iteration 1 --
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
-- Iteration 2 --
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
-- Iteration 3 --
array(2) {
[0]=>
object(test)#%d (1) {
["t"]=>
int(10)
}
[1]=>
object(test)#%d (1) {
["t"]=>
int(10)
}
}
-- Iteration 4 --
array(2) {
[0]=>
NULL
[1]=>
NULL
}
-- Iteration 5 --
array(2) {
[0]=>
NULL
[1]=>
NULL
}
Done
@@ -0,0 +1,168 @@
--TEST--
Test array_fill() function : usage variations - using return value of array_fill as 'val' arugment
--FILE--
<?php
/* Prototype : array array_fill(int $start_key, int $num, mixed $val)
* Description: Create an array containing num elements starting with index start_key each initialized to val
* Source code: ext/standard/array.c
*/
/* passing array_fill() as the 'val' argument in array_fill() function */
echo "*** Testing array_fill() : variation ***\n";
$start_key = 0;
$num = 2;
$heredoc = <<<HERE_DOC
Hello
HERE_DOC;
// array of possible valid values for 'val' arugment
$values = array (
/* 1 */ NULL,
0,
1,
/* 4 */ 1.0,
'hi',
"hi",
/* 7 */ $heredoc
);
echo "*** Filling 2 dimensional array with all basic valid values ***\n";
$counter = 1;
for($i =0; $i < count($values); $i ++)
{
echo "-- Iteration $counter --\n";
$val = $values[$i];
var_dump( array_fill($start_key, $num, array_fill($start_key, $num, $val)) );
$counter++;
}
echo "Done";
?>
--EXPECTF--
*** Testing array_fill() : variation ***
*** Filling 2 dimensional array with all basic valid values ***
-- Iteration 1 --
array(2) {
[0]=>
array(2) {
[0]=>
NULL
[1]=>
NULL
}
[1]=>
array(2) {
[0]=>
NULL
[1]=>
NULL
}
}
-- Iteration 2 --
array(2) {
[0]=>
array(2) {
[0]=>
int(0)
[1]=>
int(0)
}
[1]=>
array(2) {
[0]=>
int(0)
[1]=>
int(0)
}
}
-- Iteration 3 --
array(2) {
[0]=>
array(2) {
[0]=>
int(1)
[1]=>
int(1)
}
[1]=>
array(2) {
[0]=>
int(1)
[1]=>
int(1)
}
}
-- Iteration 4 --
array(2) {
[0]=>
array(2) {
[0]=>
float(1)
[1]=>
float(1)
}
[1]=>
array(2) {
[0]=>
float(1)
[1]=>
float(1)
}
}
-- Iteration 5 --
array(2) {
[0]=>
array(2) {
[0]=>
string(2) "hi"
[1]=>
string(2) "hi"
}
[1]=>
array(2) {
[0]=>
string(2) "hi"
[1]=>
string(2) "hi"
}
}
-- Iteration 6 --
array(2) {
[0]=>
array(2) {
[0]=>
string(2) "hi"
[1]=>
string(2) "hi"
}
[1]=>
array(2) {
[0]=>
string(2) "hi"
[1]=>
string(2) "hi"
}
}
-- Iteration 7 --
array(2) {
[0]=>
array(2) {
[0]=>
string(5) "Hello"
[1]=>
string(5) "Hello"
}
[1]=>
array(2) {
[0]=>
string(5) "Hello"
[1]=>
string(5) "Hello"
}
}
Done
@@ -0,0 +1,291 @@
--TEST--
Test array_fill() function : usage variations - different types of array values for 'val' argument
--FILE--
<?php
/* Prototype : array array_fill(int $start_key, int $num, mixed $val)
* Description: Create an array containing num elements starting with index start_key each initialized to val
* Source code: ext/standard/array.c
*/
/*
* testing array_fill() by passing different types of array values for 'val' argument
*/
echo "*** Testing array_fill() : usage variations ***\n";
// Initialise function arguments not being substituted
$start_key = 0;
$num = 2;
//array of different types of array values for 'val' argument
$values = array(
/* 1 */ array(),
array(1 , 2 , 3 , 4),
array(1 => "Hi" , 2 => "Hello"),
array("Saffron" , "White" , "Green"),
/* 5 */ array('color' => 'red' , 'item' => 'pen'),
array( 'color' => 'red' , 2 => 'green ' ),
array("colour" => "red" , "item" => "pen"),
array( TRUE => "red" , FALSE => "green" ),
array( true => "red" , FALSE => "green" ),
/* 10 */ array( 1 => "Hi" , "color" => "red" , 'item' => 'pen'),
array( NULL => "Hi", '1' => "Hello" , "1" => "Green"),
array( ""=>1, "color" => "green"),
/* 13 */ array('Saffron' , 'White' , 'Green')
);
// loop through each element of the values array for 'val' argument
// check the working of array_fill()
echo "--- Testing array_fill() with different types of array values for 'val' argument ---\n";
$counter = 1;
for($i = 0; $i < count($values); $i++)
{
echo "-- Iteration $counter --\n";
$val = $values[$i];
var_dump( array_fill($start_key, $num, $val) );
$counter++;
}
echo "Done";
?>
--EXPECTF--
*** Testing array_fill() : usage variations ***
--- Testing array_fill() with different types of array values for 'val' argument ---
-- Iteration 1 --
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
-- Iteration 2 --
array(2) {
[0]=>
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
}
[1]=>
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
}
}
-- Iteration 3 --
array(2) {
[0]=>
array(2) {
[1]=>
string(2) "Hi"
[2]=>
string(5) "Hello"
}
[1]=>
array(2) {
[1]=>
string(2) "Hi"
[2]=>
string(5) "Hello"
}
}
-- Iteration 4 --
array(2) {
[0]=>
array(3) {
[0]=>
string(7) "Saffron"
[1]=>
string(5) "White"
[2]=>
string(5) "Green"
}
[1]=>
array(3) {
[0]=>
string(7) "Saffron"
[1]=>
string(5) "White"
[2]=>
string(5) "Green"
}
}
-- Iteration 5 --
array(2) {
[0]=>
array(2) {
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
}
[1]=>
array(2) {
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
}
}
-- Iteration 6 --
array(2) {
[0]=>
array(2) {
["color"]=>
string(3) "red"
[2]=>
string(6) "green "
}
[1]=>
array(2) {
["color"]=>
string(3) "red"
[2]=>
string(6) "green "
}
}
-- Iteration 7 --
array(2) {
[0]=>
array(2) {
["colour"]=>
string(3) "red"
["item"]=>
string(3) "pen"
}
[1]=>
array(2) {
["colour"]=>
string(3) "red"
["item"]=>
string(3) "pen"
}
}
-- Iteration 8 --
array(2) {
[0]=>
array(2) {
[1]=>
string(3) "red"
[0]=>
string(5) "green"
}
[1]=>
array(2) {
[1]=>
string(3) "red"
[0]=>
string(5) "green"
}
}
-- Iteration 9 --
array(2) {
[0]=>
array(2) {
[1]=>
string(3) "red"
[0]=>
string(5) "green"
}
[1]=>
array(2) {
[1]=>
string(3) "red"
[0]=>
string(5) "green"
}
}
-- Iteration 10 --
array(2) {
[0]=>
array(3) {
[1]=>
string(2) "Hi"
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
}
[1]=>
array(3) {
[1]=>
string(2) "Hi"
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
}
}
-- Iteration 11 --
array(2) {
[0]=>
array(2) {
[""]=>
string(2) "Hi"
[1]=>
string(5) "Green"
}
[1]=>
array(2) {
[""]=>
string(2) "Hi"
[1]=>
string(5) "Green"
}
}
-- Iteration 12 --
array(2) {
[0]=>
array(2) {
[""]=>
int(1)
["color"]=>
string(5) "green"
}
[1]=>
array(2) {
[""]=>
int(1)
["color"]=>
string(5) "green"
}
}
-- Iteration 13 --
array(2) {
[0]=>
array(3) {
[0]=>
string(7) "Saffron"
[1]=>
string(5) "White"
[2]=>
string(5) "Green"
}
[1]=>
array(3) {
[0]=>
string(7) "Saffron"
[1]=>
string(5) "White"
[2]=>
string(5) "Green"
}
}
Done
@@ -0,0 +1,55 @@
--TEST--
Test array_filter() function : basic functionality
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_filter() : basic functionality ***\n";
// Initialise all required variables
$input = array(1, 2, 3, 0, -1); // 0 will be considered as FALSE and removed in default callback
/* Callback function
* Prototype : bool even(array $input)
* Parameters : $input - input array each element of which will be checked in function even()
* Return type : boolean - true if element is even and false otherwise
* Description : This function takes array as parameter and checks for each element of array.
* It returns true if the element is even number else returns false
*/
function even($input)
{
return ($input % 2 == 0);
}
// with all possible arguments
var_dump( array_filter($input,"even") );
// with default arguments
var_dump( array_filter($input) );
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : basic functionality ***
array(2) {
[1]=>
int(2)
[3]=>
int(0)
}
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[4]=>
int(-1)
}
Done
@@ -0,0 +1,50 @@
--TEST--
Test array_filter() function : error conditions
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_filter() : error conditions ***\n";
// zero arguments
echo "-- Testing array_filter() function with Zero arguments --";
var_dump( array_filter() );
$input = array(0, 1, 2, 3, 5);
/* callback function
* Prototype : bool odd(array $input)
* Parameters : $input - array for which each elements should be checked into the function
* Return Type : bool - true if element is odd and returns false otherwise
* Description : Function takes array as input and checks for its each elements.
*/
function odd($input)
{
return ($input % 2 != 0);
}
$extra_arg = 10;
// with one more than the expected number of arguments
echo "-- Testing array_filter() function with more than expected no. of arguments --";
var_dump( array_filter($input, "odd", $extra_arg) );
// with incorrect callback function
echo "-- Testing array_filter() function with incorrect callback --";
var_dump( array_filter($input, "even") );
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : error conditions ***
-- Testing array_filter() function with Zero arguments --
Warning: Wrong parameter count for array_filter() in %s on line %d
NULL
-- Testing array_filter() function with more than expected no. of arguments --
Warning: Wrong parameter count for array_filter() in %s on line %d
NULL
-- Testing array_filter() function with incorrect callback --
Warning: array_filter(): The second argument, 'even', should be a valid callback in %s on line %d
NULL
Done
@@ -0,0 +1,155 @@
--TEST--
Test array_filter() function : object functionality
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/* This file uses 'input' array with different types of objects and passes
* it to array_filter() to test object functionality
* i.e. object of simple class with members and functions
* object of empty class
* object of child class extending abstract class
* object of class containing static member
*/
echo "*** Testing array_filter() : object functionality ***\n";
// simple class with members - variable and method
class SimpleClass
{
public $var1 = 10;
public function check() {
return $var1;
}
}
// class without members
class EmptyClass
{
}
// abstract class
abstract class AbstractClass
{
protected $var2 = 5;
abstract function emptyMethod();
}
// class deriving above abstract class
class ChildClass extends AbstractClass
{
private $var3;
public function emptyMethod() {
echo "defined in child";
}
}
// class with final method
class FinalClass
{
private $var4;
final function finalMethod() {
echo 'This can not be overloaded';
}
}
// class with static members
class StaticClass
{
static $var5 = 5;
public static function staticMethod() {
echo 'this is static method';
}
}
// Callback function which returns always true
function always_true($input)
{
return true;
}
// Callback function which returns always false
function always_false($input)
{
return false;
}
// 'input' array containing objects as elements
$input = array(
new SimpleClass(),
new EmptyClass(),
new ChildClass(),
new FinalClass(),
new StaticClass()
);
// with default callback
var_dump( array_filter($input) );
// with always_true callback function
var_dump( array_filter($input, "always_true") );
// with always_false callback function
var_dump( array_filter($input, "always_false") );
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : object functionality ***
array(5) {
[0]=>
object(SimpleClass)#%d (1) {
["var1"]=>
int(10)
}
[1]=>
object(EmptyClass)#%d (0) {
}
[2]=>
object(ChildClass)#%d (2) {
["var3:private"]=>
NULL
["var2:protected"]=>
int(5)
}
[3]=>
object(FinalClass)#%d (1) {
["var4:private"]=>
NULL
}
[4]=>
object(StaticClass)#%d (0) {
}
}
array(5) {
[0]=>
object(SimpleClass)#%d (1) {
["var1"]=>
int(10)
}
[1]=>
object(EmptyClass)#%d (0) {
}
[2]=>
object(ChildClass)#%d (2) {
["var3:private"]=>
NULL
["var2:protected"]=>
int(5)
}
[3]=>
object(FinalClass)#%d (1) {
["var4:private"]=>
NULL
}
[4]=>
object(StaticClass)#%d (0) {
}
}
array(0) {
}
Done
@@ -0,0 +1,195 @@
--TEST--
Test array_filter() function : usage variations - Unexpected values for 'input' argument
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/* Testing different scalar and non-scalar values for 'input' argument
*/
echo "*** Testing array_filter() : usage variations - unexpected values for 'input'***\n";
/* Callback function
* Prototype : bool always_true(array $input)
* Parameters : array for which each elements needs to be used in function
* Return value : Returns true for each element
* Discription : function applied to each element of the passed array and returns true
*/
function always_true($input)
{
return true;
}
// 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');
// different values for 'input' argument
$input_values = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
// string data
/*18*/ "string",
'string',
// object data
/*20*/ new MyClass(),
// resource data
$fp,
// undefined data
@$undefined_var,
// unset data
/*23*/ @$unset_var,
);
// loop through each element of the array for input
for($count = 0; $count < count($input_values); $count++) {
echo "-- Iteration ".($count + 1)." --\n";
var_dump( array_filter($input_values[$count],"always_true") );
};
// closing resource
fclose($fp);
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : usage variations - unexpected values for 'input'***
-- Iteration 1 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 2 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 3 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 4 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 5 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 6 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 7 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 8 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 9 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 10 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 11 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 12 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 13 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 14 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 15 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 16 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 17 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 18 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 19 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 20 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 21 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 22 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
-- Iteration 23 --
Warning: array_filter(): The first argument should be an array in %s on line %d
NULL
Done
@@ -0,0 +1,184 @@
--TEST--
Test array_filter() function : usage variations - Unexpected values for 'callback' function argument
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/* Testing different scalar non-scalar values in place of 'callback' argument
*/
echo "*** Testing array_filter() : usage variations - unexpected values for 'callback' function***\n";
// Initialise variables
$input = array('value1', 'value2', 'value3', 'value4');
//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');
// different scalar/non-scalar values inplace of 'callback'
$values = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-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
/*17*/ true,
false,
TRUE,
FALSE,
// empty data
/*21*/ "",
'',
// string data
/*23*/ "string",
'string',
// object data
/*25*/ new MyClass(),
// resource data
$fp,
// undefined data
@$undefined_var,
// unset data
/*28*/ @$unset_var,
);
// loop through each element of the 'values' for callback
for($count = 0; $count < count($values); $count++) {
echo "-- Iteration ".($count + 1)." --";
var_dump( array_filter($input, $values[$count]) );
};
// closing resource
fclose($fp);
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : usage variations - unexpected values for 'callback' function***
-- Iteration 1 --
Warning: array_filter(): The second argument, '0', should be a valid callback in %s on line %d
NULL
-- Iteration 2 --
Warning: array_filter(): The second argument, '1', should be a valid callback in %s on line %d
NULL
-- Iteration 3 --
Warning: array_filter(): The second argument, '12345', should be a valid callback in %s on line %d
NULL
-- Iteration 4 --
Warning: array_filter(): The second argument, '-2345', should be a valid callback in %s on line %d
NULL
-- Iteration 5 --
Warning: array_filter(): The second argument, '10.5', should be a valid callback in %s on line %d
NULL
-- Iteration 6 --
Warning: array_filter(): The second argument, '-10.5', should be a valid callback in %s on line %d
NULL
-- Iteration 7 --
Warning: array_filter(): The second argument, '123456789000', should be a valid callback in %s on line %d
NULL
-- Iteration 8 --
Warning: array_filter(): The second argument, '1.23456789E-9', should be a valid callback in %s on line %d
NULL
-- Iteration 9 --
Warning: array_filter(): The second argument, '0.5', should be a valid callback in %s on line %d
NULL
-- Iteration 10 --
Warning: array_filter(): The second argument, 'Array', should be a valid callback in %s on line %d
NULL
-- Iteration 11 --
Warning: array_filter(): The second argument, 'Array', should be a valid callback in %s on line %d
NULL
-- Iteration 12 --
Warning: array_filter(): The second argument, 'Array', should be a valid callback in %s on line %d
NULL
-- Iteration 13 --
Warning: array_filter(): The second argument, 'Array', should be a valid callback in %s on line %d
NULL
-- Iteration 14 --
Warning: array_filter(): The second argument, 'Array', should be a valid callback in %s on line %d
NULL
-- Iteration 15 --
Warning: array_filter(): The second argument, '', should be a valid callback in %s on line %d
NULL
-- Iteration 16 --
Warning: array_filter(): The second argument, '', should be a valid callback in %s on line %d
NULL
-- Iteration 17 --
Warning: array_filter(): The second argument, '1', should be a valid callback in %s on line %d
NULL
-- Iteration 18 --
Warning: array_filter(): The second argument, '', should be a valid callback in %s on line %d
NULL
-- Iteration 19 --
Warning: array_filter(): The second argument, '1', should be a valid callback in %s on line %d
NULL
-- Iteration 20 --
Warning: array_filter(): The second argument, '', should be a valid callback in %s on line %d
NULL
-- Iteration 21 --
Warning: array_filter(): The second argument, '', should be a valid callback in %s on line %d
NULL
-- Iteration 22 --
Warning: array_filter(): The second argument, '', should be a valid callback in %s on line %d
NULL
-- Iteration 23 --
Warning: array_filter(): The second argument, 'string', should be a valid callback in %s on line %d
NULL
-- Iteration 24 --
Warning: array_filter(): The second argument, 'string', should be a valid callback in %s on line %d
NULL
-- Iteration 25 --
Warning: array_filter(): The second argument, 'object', should be a valid callback in %s on line %d
NULL
-- Iteration 26 --
Warning: array_filter(): The second argument, %s, should be a valid callback in %s on line %d
NULL
-- Iteration 27 --
Warning: array_filter(): The second argument, '', should be a valid callback in %s on line %d
NULL
-- Iteration 28 --
Warning: array_filter(): The second argument, '', should be a valid callback in %s on line %d
NULL
Done
@@ -0,0 +1,216 @@
--TEST--
Test array_filter() function : usage variations - Different types of array for 'input' argument
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/*
* Passing different types of array as 'input' argument.
*/
// callback function returning always false
function always_false($input)
{
return false;
}
// callback function returning always true
function always_true($input)
{
return true;
}
echo "*** Testing array_filter() : usage variations - different types of array for 'input' argument***\n";
// different types of 'input' array
$input_values = array(
array(0, 1, 2, -1, 034, 0X4A), // integer values
array(0.0, 1.2, 1.2e3, 1.2e-3), // float values
array('value1', "value2", '', " ", ""), // string values
array(true, false, TRUE, FALSE), // bool values
array(null, NULL), // null values
array(1 => 'one', 'zero' => 0, -2 => "value"), //associative array
array("one" => 1, null => 'null', 5.2 => "float", true => 1, "" => 'empty'), // associative array with different keys
array(1 => 'one', 2, "key" => 'value') // combinition of associative and non-associative array
);
// loop through each element of 'input' with default callback
for($count = 0; $count < count($input_values); $count++)
{
echo "-- Iteration ".($count + 1). " --\n";
var_dump( array_filter($input_values[$count]) );
var_dump( array_filter($input_values[$count], 'always_true') );
var_dump( array_filter($input_values[$count], 'always_false') );
}
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : usage variations - different types of array for 'input' argument***
-- Iteration 1 --
array(5) {
[1]=>
int(1)
[2]=>
int(2)
[3]=>
int(-1)
[4]=>
int(28)
[5]=>
int(74)
}
array(6) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(2)
[3]=>
int(-1)
[4]=>
int(28)
[5]=>
int(74)
}
array(0) {
}
-- Iteration 2 --
array(3) {
[1]=>
float(1.2)
[2]=>
float(1200)
[3]=>
float(0.0012)
}
array(4) {
[0]=>
float(0)
[1]=>
float(1.2)
[2]=>
float(1200)
[3]=>
float(0.0012)
}
array(0) {
}
-- Iteration 3 --
array(3) {
[0]=>
string(6) "value1"
[1]=>
string(6) "value2"
[3]=>
string(1) " "
}
array(5) {
[0]=>
string(6) "value1"
[1]=>
string(6) "value2"
[2]=>
string(0) ""
[3]=>
string(1) " "
[4]=>
string(0) ""
}
array(0) {
}
-- Iteration 4 --
array(2) {
[0]=>
bool(true)
[2]=>
bool(true)
}
array(4) {
[0]=>
bool(true)
[1]=>
bool(false)
[2]=>
bool(true)
[3]=>
bool(false)
}
array(0) {
}
-- Iteration 5 --
array(0) {
}
array(2) {
[0]=>
NULL
[1]=>
NULL
}
array(0) {
}
-- Iteration 6 --
array(2) {
[1]=>
string(3) "one"
[-2]=>
string(5) "value"
}
array(3) {
[1]=>
string(3) "one"
["zero"]=>
int(0)
[-2]=>
string(5) "value"
}
array(0) {
}
-- Iteration 7 --
array(4) {
["one"]=>
int(1)
[""]=>
string(5) "empty"
[5]=>
string(5) "float"
[1]=>
int(1)
}
array(4) {
["one"]=>
int(1)
[""]=>
string(5) "empty"
[5]=>
string(5) "float"
[1]=>
int(1)
}
array(0) {
}
-- Iteration 8 --
array(3) {
[1]=>
string(3) "one"
[2]=>
int(2)
["key"]=>
string(5) "value"
}
array(3) {
[1]=>
string(3) "one"
[2]=>
int(2)
["key"]=>
string(5) "value"
}
array(0) {
}
Done
@@ -0,0 +1,97 @@
--TEST--
Test array_filter() function : usage variations - Different types of 'callback' function
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/*
* Passing different types of callback functions to array_filter()
* with parameter and return
* with paramter and without return
* without parameter and with return
* without parameter and without return
*/
echo "*** Testing array_filter() : usage variation - different 'callback' functions***\n";
// Initialize variables
$input = array(0, -1, 2, 3.4E-3, 'hello', "value", "key" => 4, 'null' => NULL);
// callback function without parameters and with return value
function callback1()
{
return 1;
}
echo "-- Callback function without parameter and with return --\n";
var_dump( array_filter($input, "callback1") );
// callback function with parameter and without return value
function callback2($input)
{
}
echo "-- Callback funciton with parameter and without return --\n";
var_dump( array_filter($input, "callback2") );
// callback function without parameter and without return value
function callback3()
{
}
echo "-- Callback function without parameter and return --\n";
var_dump( array_filter($input, "callback3") );
// callback function with parameter and with return value
function callback4($input)
{
if($input > 0 ) {
return true;
}
else {
return false;
}
}
echo "-- Callback function with parameter and return --\n";
var_dump( array_filter($input, "callback4") );
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : usage variation - different 'callback' functions***
-- Callback function without parameter and with return --
array(8) {
[0]=>
int(0)
[1]=>
int(-1)
[2]=>
int(2)
[3]=>
float(0.0034)
[4]=>
string(5) "hello"
[5]=>
string(5) "value"
["key"]=>
int(4)
["null"]=>
NULL
}
-- Callback funciton with parameter and without return --
array(0) {
}
-- Callback function without parameter and return --
array(0) {
}
-- Callback function with parameter and return --
array(3) {
[2]=>
int(2)
[3]=>
float(0.0034)
["key"]=>
int(4)
}
Done
@@ -0,0 +1,109 @@
--TEST--
Test array_filter() function : usage variations - 'input' argument with different false entries
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/*
* With default callback function argument, array_filter() removes elements which are interpreted as false
* Here Testing all the false array element possibilities
*/
// callback function always_true
function always_true($input)
{
return true;
}
// callback function always_false
function always_false($input)
{
return false;
}
echo "*** Testing array_filter() : usage variations - different false elements in 'input' ***\n";
// unset variable
$unset_var = 10;
unset($unset_var);
// empty heredoc string
$empty_heredoc =<<<EOT
EOT;
// input array with different false elements
$input = array(
false,
False,
'',
"",
0,
0.0,
null,
NULL,
"0",
'0',
array(),
!1,
1==2,
$empty_heredoc,
@$unset_var,
@$undefined_var,
);
// With default callback function
var_dump( array_filter($input) );
// With callback function which returns always true
var_dump( array_filter($input, 'always_true') );
// With callback function which returns always false
var_dump( array_filter($input, 'always_false') );
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : usage variations - different false elements in 'input' ***
array(0) {
}
array(16) {
[0]=>
bool(false)
[1]=>
bool(false)
[2]=>
string(0) ""
[3]=>
string(0) ""
[4]=>
int(0)
[5]=>
float(0)
[6]=>
NULL
[7]=>
NULL
[8]=>
string(1) "0"
[9]=>
string(1) "0"
[10]=>
array(0) {
}
[11]=>
bool(false)
[12]=>
bool(false)
[13]=>
string(0) ""
[14]=>
NULL
[15]=>
NULL
}
array(0) {
}
Done
@@ -0,0 +1,94 @@
--TEST--
Test array_filter() function : usage variations - 'input' array containing references
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/*
* Passing 'input' array which contains elements as reference to other data
*/
echo "*** Testing array_filter() : usage variations - 'input' containing references ***\n";
// Callback function
/* Prototype : bool callback(array $input)
* Parameter : $input - array of which each element need to be checked in function
* Return Type : returns true or false
* Description : This function checks each element of an input array if element > 5 then
* returns true else returns false
*/
function callback($input)
{
if($input > 5) {
return true;
}
else {
return false;
}
}
// initializing variables
$value1 = array(1, 2, 8);
$value2 = array(5, 6, 4);
$input = array(&$value1, 10, &$value2, 'value');
// with 'callback' argument
var_dump( array_filter($input, 'callback') );
// with default 'callback' argument
var_dump( array_filter($input) );
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : usage variations - 'input' containing references ***
array(3) {
[0]=>
&array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(8)
}
[1]=>
int(10)
[2]=>
&array(3) {
[0]=>
int(5)
[1]=>
int(6)
[2]=>
int(4)
}
}
array(4) {
[0]=>
&array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(8)
}
[1]=>
int(10)
[2]=>
&array(3) {
[0]=>
int(5)
[1]=>
int(6)
[2]=>
int(4)
}
[3]=>
string(5) "value"
}
Done
@@ -0,0 +1,80 @@
--TEST--
Test array_filter() function : usage variations - anonymous callback functions
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/*
* Passing different anonymous callback functions with passed by value and reference arguments,
*/
echo "*** Testing array_filter() : usage variations - Anonymous callback functions ***\n";
$input = array(0, 1, -1, 10, 100, 1000, 'Hello', null);
// anonymous callback function
echo "Anonymous callback function with regular parameter and statement\n";
var_dump( array_filter($input, create_function('$input', 'return ($input > 1);') ) );
// anonymous callback function with reference
echo "Anonymous callback function with reference parameter\n";
var_dump( array_filter($input, create_function('&$input', 'return ($input < 1);') ) );
// anonymous callback function with null argument
echo "Anonymous callback funciton with null argument\n";
var_dump( array_filter($input, create_function(null, 'return true;') ) );
// anonymous callback function with argument and null statement
echo "Anonymous callback function with regular argument and null statement\n";
var_dump( array_filter($input, create_function('$input', null) ) );
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : usage variations - Anonymous callback functions ***
Anonymous callback function with regular parameter and statement
array(3) {
[3]=>
int(10)
[4]=>
int(100)
[5]=>
int(1000)
}
Anonymous callback function with reference parameter
array(4) {
[0]=>
int(0)
[2]=>
int(-1)
[6]=>
string(5) "Hello"
[7]=>
NULL
}
Anonymous callback funciton with null argument
array(8) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(-1)
[3]=>
int(10)
[4]=>
int(100)
[5]=>
int(1000)
[6]=>
string(5) "Hello"
[7]=>
NULL
}
Anonymous callback function with regular argument and null statement
array(0) {
}
Done
@@ -0,0 +1,151 @@
--TEST--
Test array_filter() function : usage variations - Callback function with different return values
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/*
* callback functions are expected to return bool value for array_filter()
* here testing callback functions for return values other than bool
*/
echo "*** Testing array_filter() : usage variations - callback function with different return values***\n";
$input = array(0, 1, -1, 10, 100, 1000, 'Hello', null, true);
// callback functions
// int as return value
function callback1($input)
{
return 5;
}
echo "callback function with int return value\n";
var_dump( array_filter($input, 'callback1') );
// float as return value
function callback2($input)
{
return 3.4;
}
echo "callback function with float return value\n";
var_dump( array_filter($input, 'callback2') );
// string as return value
function callback3($input)
{
return 'value';
}
echo "callback function with string return value\n";
var_dump( array_filter($input, 'callback3') );
// null as return value
function callback4($input)
{
return null;
}
echo "callback function with null return value\n";
var_dump( array_filter($input, 'callback4') );
// array as return value
function callback5($input)
{
return array(8);
}
echo "callback function with array as return value\n";
var_dump( array_filter($input, 'callback5') );
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : usage variations - callback function with different return values***
callback function with int return value
array(9) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(-1)
[3]=>
int(10)
[4]=>
int(100)
[5]=>
int(1000)
[6]=>
string(5) "Hello"
[7]=>
NULL
[8]=>
bool(true)
}
callback function with float return value
array(9) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(-1)
[3]=>
int(10)
[4]=>
int(100)
[5]=>
int(1000)
[6]=>
string(5) "Hello"
[7]=>
NULL
[8]=>
bool(true)
}
callback function with string return value
array(9) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(-1)
[3]=>
int(10)
[4]=>
int(100)
[5]=>
int(1000)
[6]=>
string(5) "Hello"
[7]=>
NULL
[8]=>
bool(true)
}
callback function with null return value
array(0) {
}
callback function with array as return value
array(9) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(-1)
[3]=>
int(10)
[4]=>
int(100)
[5]=>
int(1000)
[6]=>
string(5) "Hello"
[7]=>
NULL
[8]=>
bool(true)
}
Done
@@ -0,0 +1,72 @@
--TEST--
Test array_filter() function : usage variations - built-in functions as 'callback' argument
--FILE--
<?php
/* Prototype : array array_filter(array $input [, callback $callback])
* Description: Filters elements from the array via the callback.
* Source code: ext/standard/array.c
*/
/*
* Passing built-in functions and different language constructs as 'callback' argument
*/
echo "*** Testing array_filter() : usage variations - built-in functions as 'callback' argument ***\n";
$input = array(0, 1, -1, 10, 100, 1000, 'Hello', null);
// using built-in function 'is_int' as 'callback'
var_dump( array_filter($input, 'is_int') );
// using built-in function 'chr' as 'callback'
var_dump( array_filter($input, 'chr') );
// using language construct 'echo' as 'callback'
var_dump( array_filter($input, 'echo') );
// using language construct 'exit' as 'callback'
var_dump( array_filter($input, 'exit') );
echo "Done"
?>
--EXPECTF--
*** Testing array_filter() : usage variations - built-in functions as 'callback' argument ***
array(6) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(-1)
[3]=>
int(10)
[4]=>
int(100)
[5]=>
int(1000)
}
array(8) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(-1)
[3]=>
int(10)
[4]=>
int(100)
[5]=>
int(1000)
[6]=>
string(5) "Hello"
[7]=>
NULL
}
Warning: array_filter(): The second argument, 'echo', should be a valid callback in %s on line %d
NULL
Warning: array_filter(): The second argument, 'exit', should be a valid callback in %s on line %d
NULL
Done
@@ -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,80 @@
--TEST--
Test array_intersect() function : basic functionality
--FILE--
<?php
/* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
* Description: Returns the entries of arr1 that have values which are present in all the other arguments
* Source code: ext/standard/array.c
*/
/*
* Testing the behavior of array_intersect() by passing different arrays for the arguments.
* Function is tested by passing associative array as well as array with default keys.
*/
echo "*** Testing array_intersect() : basic functionality ***\n";
// array with default keys
$arr_default_keys = array(1, 2, "hello", 'world');
// associative array
$arr_associative = array("one" => 1, "two" => 2);
// default key array for both $arr1 and $arr2 argument
var_dump( array_intersect($arr_default_keys, $arr_default_keys) );
// default key array for $arr1 and associative array for $arr2 argument
var_dump( array_intersect($arr_default_keys, $arr_associative) );
// associative array for $arr1 and default key array for $arr2
var_dump( array_intersect($arr_associative, $arr_default_keys) );
// associative array for both $arr1 and $arr2 argument
var_dump( array_intersect($arr_associative, $arr_associative) );
// more arrays to be intersected
$arr3 = array(2, 3, 4);
var_dump( array_intersect($arr_default_keys, $arr_associative, $arr3) );
var_dump( array_intersect($arr_associative, $arr_default_keys, $arr3, $arr_associative) );
echo "Done";
?>
--EXPECTF--
*** Testing array_intersect() : basic functionality ***
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
string(5) "hello"
[3]=>
string(5) "world"
}
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
array(1) {
[1]=>
int(2)
}
array(1) {
["two"]=>
int(2)
}
Done
@@ -0,0 +1,35 @@
--TEST--
Test array_intersect() function : error conditions
--FILE--
<?php
/* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
* Description: Returns the entries of arr1 that have values which are present in all the other arguments
* Source code: ext/standard/array.c
*/
echo "*** Testing array_intersect() : error conditions ***\n";
// Testing array_intersect() with zero arguments
echo "\n-- Testing array_intersect() function with Zero arguments --\n";
var_dump( array_intersect() );
// Testing array_intersect() with one less than the expected number of arguments
echo "\n-- Testing array_intersect() function with less than expected no. of arguments --\n";
$arr1 = array(1, 2);
var_dump( array_intersect($arr1) );
echo "Done";
?>
--EXPECTF--
*** Testing array_intersect() : error conditions ***
-- Testing array_intersect() function with Zero arguments --
Warning: Wrong parameter count for array_intersect() in %s on line %d
NULL
-- Testing array_intersect() function with less than expected no. of arguments --
Warning: Wrong parameter count for array_intersect() in %s on line %d
NULL
Done
@@ -0,0 +1,280 @@
--TEST--
Test array_intersect() function : usage variations - unexpected values for 'arr1' argument
--FILE--
<?php
/* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
* Description: Returns the entries of arr1 that have values which are present in all the other arguments
* Source code: ext/standard/array.c
*/
/*
* Testing array_intersect() function by passing values to $arr1 argument other than arrays
* and see that function emits proper warning messages wherever expected.
* The $arr2 argument is a fixed array.
*/
echo "*** Testing array_intersect() : Passing non-array values to \$arr1 argument ***\n";
// array to be passsed to $arr2 as default argument
$arr2 = array(1, 2);
// array to be passed to optional argument
$arr3 = array(1, 2, "one" => 1, "two" => 2);
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// unexpected values to be passed to $arr1 argument
$arrays = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
// string data
/*18*/ "string",
'string',
$heredoc,
// object data
/*21*/ new classA(),
// undefined data
/*22*/ @$undefined_var,
// unset data
/*23*/ @$unset_var,
// resource variable
/*24*/ $fp
);
// loop through each sub-array within $arrrays to check the behavior of array_intersect()
$iterator = 1;
foreach($arrays as $unexpected_value) {
echo "\n-- Iterator $iterator --";
// Calling array_intersect() with default arguments
var_dump( array_intersect($unexpected_value,$arr2) );
// Calling array_intersect() with more arguments
var_dump( array_intersect($unexpected_value, $arr2, $arr3) );
$iterator++;
}
// close the file resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_intersect() : Passing non-array values to $arr1 argument ***
-- Iterator 1 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 2 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 3 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 4 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 5 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 6 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 7 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 8 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 9 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 10 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 11 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 12 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 13 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 14 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 15 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 16 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 17 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 18 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 19 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 20 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 21 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 22 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 23 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
-- Iterator 24 --
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #1 is not an array in %s on line %d
NULL
Done
@@ -0,0 +1,53 @@
--TEST--
Test array_intersect() function : usage variations - binary safe checking
--FILE--
<?php
/* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
* Description: Returns the entries of arr1 that have values which are present in all the other arguments
* Source code: ext/standard/array.c
*/
/*
* Testing the behavior of array_intersect() by passing array with
* binary values for $arr1 and $arr2 argument.
*/
echo "*** Testing array_intersect() : binary safe checking ***\n";
// array with binary values
$arr_binary = array(b"hello", b"world");
// simple array
$arr_normal = array("hello", "world");
// array with binary value for $arr1 argument
var_dump( array_intersect($arr_binary, $arr_normal) );
// array with binary value for $arr2 argument
var_dump( array_intersect($arr_normal, $arr_binary) );
// array with binary value for both $arr1 and $arr2 argument
var_dump( array_intersect($arr_binary, $arr_binary) );
echo "Done";
?>
--EXPECTF--
*** Testing array_intersect() : binary safe checking ***
array(2) {
[0]=>
string(5) "hello"
[1]=>
string(5) "world"
}
array(2) {
[0]=>
string(5) "hello"
[1]=>
string(5) "world"
}
array(2) {
[0]=>
string(5) "hello"
[1]=>
string(5) "world"
}
Done
@@ -0,0 +1,281 @@
--TEST--
Test array_intersect() function : usage variations - unexpected values for 'arr2' argument
--FILE--
<?php
/* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
* Description: Returns the entries of arr1 that have values which are present in all the other arguments
* Source code: ext/standard/array.c
*/
/*
* Testing array_intersect() function by passing values to $arr2 argument other than arrays
* and see that function emits proper warning messages wherever expected.
* The $arr1 argument is a fixed array.
*/
echo "*** Testing array_intersect() : Passing non-array values to \$arr2 argument ***\n";
// array to be passsed to $arr1 as default argument
$arr1 = array(1, 2);
// arrays to be passed to optional argument
$arr3 = array(1, 2, "one" => 1, "two" => 2);
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// unexpected values to be passed to $arr2 argument
$arrays = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
// string data
/*18*/ "string",
'string',
$heredoc,
// object data
/*21*/ new classA(),
// undefined data
/*22*/ @$undefined_var,
// unset data
/*23*/ @$unset_var,
// resource variable
/*24*/ $fp
);
// loop through each sub-array within $arrrays to check the behavior of array_intersect()
$iterator = 1;
foreach($arrays as $unexpected_value) {
echo "\n-- Iterator $iterator --";
// Calling array_intersect() with default arguments
var_dump( array_intersect($arr1,$unexpected_value) );
// Calling array_intersect() with more arguments
var_dump( array_intersect($arr1, $unexpected_value, $arr3) );
$iterator++;
}
// close the file resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_intersect() : Passing non-array values to $arr2 argument ***
-- Iterator 1 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 2 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 3 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 4 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 5 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 6 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 7 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 8 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 9 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 10 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 11 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 12 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 13 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 14 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 15 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 16 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 17 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 18 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 19 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 20 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 21 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 22 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 23 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
-- Iterator 24 --
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect(): Argument #2 is not an array in %s on line %d
NULL
Done
@@ -0,0 +1,346 @@
--TEST--
Test array_intersect() function : usage variations - different arrays for 'arr1' argument
--FILE--
<?php
/* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
* Description: Returns the entries of arr1 that have values which are present in all the other arguments
* Source code: ext/standard/array.c
*/
/*
* Passing different types of arrays to $arr1 argument and testing whether
* array_intersect() behaves in expected way with the other arguments passed to the function
* The $arr2 argument is a fixed array.
*/
echo "*** Testing array_intersect() : Passing different types of arrays to \$arr1 argument ***\n";
/* Different heredoc strings passed as argument to $arr1 */
// heredoc with blank line
$blank_line = <<<EOT
EOT;
// heredoc with multiline string
$multiline_string = <<<EOT
hello world
The big brown fox jumped over;
the lazy dog
This is a double quoted string
EOT;
// heredoc with diferent whitespaces
$diff_whitespaces = <<<EOT
hello\r world\t
1111\t\t != 2222\v\v
heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
EOT;
// heredoc with quoted strings and numeric values
$numeric_string = <<<EOT
11 < 12. 123 >22
'single quoted string'
"double quoted string"
2222 != 1111.\t 0000 = 0000\n
EOT;
// arrays to be passed to $arr1 argument
$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(false,true), // array with default keys and boolean values
array(), // empty array
/*5*/ array(NULL), // array with NULL
array("a\v\f","aaaa\r","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // array with double quoted strings
array('a\v\f','aaaa\r','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // array with single quoted strings
array($blank_line, $multiline_string, $diff_whitespaces, $numeric_string), // array with heredocs
// associative arrays
/*9*/ 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
/*14*/ 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
/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
);
// array to be passsed to $arr2 argument
$arr2 = array (
1, 1.1, "hello", "one", NULL, 2,
'world', true, false, false => 5, 'aaaa\r', "aaaa\r",
$numeric_string, $diff_whitespaces,
"one" => "ten", 4 => "four", "two" => 2, 2 => "two",
'', null => "null", '' => 'emptys'
);
// loop through each sub-array within $arrrays to check the behavior of array_intersect()
$iterator = 1;
foreach($arrays as $arr1) {
echo "-- Iterator $iterator --\n";
// Calling array_intersect() with default arguments
var_dump( array_intersect($arr1, $arr2) );
// Calling array_intersect() with more arguments.
// additional argument passed is the same as $arr1 argument
var_dump( array_intersect($arr1, $arr2, $arr1) );
$iterator++;
}
echo "Done";
?>
--EXPECTF--
*** Testing array_intersect() : Passing different types of arrays to $arr1 argument ***
-- Iterator 1 --
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
-- Iterator 2 --
array(1) {
[0]=>
float(1.1)
}
array(1) {
[0]=>
float(1.1)
}
-- Iterator 3 --
array(2) {
[0]=>
bool(false)
[1]=>
bool(true)
}
array(2) {
[0]=>
bool(false)
[1]=>
bool(true)
}
-- Iterator 4 --
array(0) {
}
array(0) {
}
-- Iterator 5 --
array(1) {
[0]=>
NULL
}
array(1) {
[0]=>
NULL
}
-- Iterator 6 --
array(1) {
[1]=>
string(5) "aaaa
"
}
array(1) {
[1]=>
string(5) "aaaa
"
}
-- Iterator 7 --
array(1) {
[1]=>
string(6) "aaaa\r"
}
array(1) {
[1]=>
string(6) "aaaa\r"
}
-- Iterator 8 --
array(2) {
[2]=>
string(88) "hello
world
1111 != 2222
heredoc
double quoted string. with different white spaces"
[3]=>
string(90) "11 < 12. 123 >22
'single quoted string'
"double quoted string"
2222 != 1111. 0000 = 0000
"
}
array(2) {
[2]=>
string(88) "hello
world
1111 != 2222
heredoc
double quoted string. with different white spaces"
[3]=>
string(90) "11 < 12. 123 >22
'single quoted string'
"double quoted string"
2222 != 1111. 0000 = 0000
"
}
-- Iterator 9 --
array(2) {
[1]=>
string(3) "one"
[2]=>
string(3) "two"
}
array(2) {
[1]=>
string(3) "one"
[2]=>
string(3) "two"
}
-- Iterator 10 --
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
-- Iterator 11 --
array(0) {
}
array(0) {
}
-- Iterator 12 --
array(1) {
["one"]=>
string(3) "ten"
}
array(1) {
["one"]=>
string(3) "ten"
}
-- Iterator 13 --
array(3) {
["one"]=>
int(1)
[2]=>
string(3) "two"
[4]=>
string(4) "four"
}
array(3) {
["one"]=>
int(1)
[2]=>
string(3) "two"
[4]=>
string(4) "four"
}
-- Iterator 14 --
array(2) {
["NULL"]=>
NULL
["null"]=>
NULL
}
array(2) {
["NULL"]=>
NULL
["null"]=>
NULL
}
-- Iterator 15 --
array(2) {
["false"]=>
bool(false)
["true"]=>
bool(true)
}
array(2) {
["false"]=>
bool(false)
["true"]=>
bool(true)
}
-- Iterator 16 --
array(3) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
["emptys"]=>
string(0) ""
}
array(3) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
["emptys"]=>
string(0) ""
}
-- Iterator 17 --
array(6) {
[1]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
NULL
[4]=>
NULL
[5]=>
bool(false)
[6]=>
bool(true)
}
array(6) {
[1]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
NULL
[4]=>
NULL
[5]=>
bool(false)
[6]=>
bool(true)
}
-- Iterator 18 --
array(1) {
[0]=>
int(5)
}
array(1) {
[0]=>
int(5)
}
-- Iterator 19 --
array(0) {
}
array(0) {
}
Done
@@ -0,0 +1,353 @@
--TEST--
Test array_intersect() function : usage variations - different arrays for 'arr2' argument
--FILE--
<?php
/* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
* Description: Returns the entries of arr1 that have values which are present in all the other arguments
* Source code: ext/standard/array.c
*/
/*
* Passing different types of arrays to $arr2 argument and testing whether
* array_intersect() behaves in expected way with the other arguments passed to the function.
* The $arr1 argument is a fixed array.
*/
echo "*** Testing array_intersect() : Passing different types of arrays to \$arr2 argument ***\n";
/* Different heredoc strings passed as argument to $arr2 */
// heredoc with blank line
$blank_line = <<<EOT
EOT;
// heredoc with multiline string
$multiline_string = <<<EOT
hello world
The big brown fox jumped over;
the lazy dog
This is a double quoted string
EOT;
// heredoc with diferent whitespaces
$diff_whitespaces = <<<EOT
hello\r world\t
1111\t\t != 2222\v\v
heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
EOT;
// heredoc with quoted strings and numeric values
$numeric_string = <<<EOT
11 < 12. 123 >22
'single quoted string'
"double quoted string"
2222 != 1111.\t 0000 = 0000\n
EOT;
// array to be passsed to $arr1 argument
$arr1 = array (
1, 1.1, "hello", "one", NULL, 2,
'world', true, false, false => 5, 'aaaa\r', "aaaa\r",
$numeric_string, $diff_whitespaces,
"one" => "ten", 4 => "four", "two" => 2, 2 => "two",
'', null => "null", '' => 'emptys'
);
// arrays to be passed to $arr2 argument
$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(false,true), // array with default keys and boolean values
array(), // empty array
/*5*/ array(NULL), // array with NULL
array("a\v\f","aaaa\r","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // array with double quoted strings
array('a\v\f','aaaa\r','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // array with single quoted strings
array($blank_line, $multiline_string, $diff_whitespaces, $numeric_string), // array with heredocs
// associative arrays
/*9*/ 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
/*14*/ 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
/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
);
// loop through each sub-array within $arrrays to check the behavior of array_intersect()
$iterator = 1;
foreach($arrays as $arr2) {
echo "-- Iteration $iterator --\n";
// Calling array_intersect() with default arguments
var_dump( array_intersect($arr1, $arr2) );
// Calling array_intersect() with more arguments
// additional argument passed is the same as $arr1 argument
var_dump( array_intersect($arr1, $arr2, $arr1) );
$iterator++;
}
echo "Done";
?>
--EXPECTF--
*** Testing array_intersect() : Passing different types of arrays to $arr2 argument ***
-- Iteration 1 --
array(3) {
[5]=>
int(2)
[7]=>
bool(true)
["two"]=>
int(2)
}
array(3) {
[5]=>
int(2)
[7]=>
bool(true)
["two"]=>
int(2)
}
-- Iteration 2 --
array(1) {
[1]=>
float(1.1)
}
array(1) {
[1]=>
float(1.1)
}
-- Iteration 3 --
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
string(0) ""
}
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
string(0) ""
}
-- Iteration 4 --
array(0) {
}
array(0) {
}
-- Iteration 5 --
array(2) {
[8]=>
bool(false)
[13]=>
string(0) ""
}
array(2) {
[8]=>
bool(false)
[13]=>
string(0) ""
}
-- Iteration 6 --
array(1) {
[10]=>
string(5) "aaaa
"
}
array(1) {
[10]=>
string(5) "aaaa
"
}
-- Iteration 7 --
array(1) {
[9]=>
string(6) "aaaa\r"
}
array(1) {
[9]=>
string(6) "aaaa\r"
}
-- Iteration 8 --
array(2) {
[11]=>
string(90) "11 < 12. 123 >22
'single quoted string'
"double quoted string"
2222 != 1111. 0000 = 0000
"
[12]=>
string(88) "hello
world
1111 != 2222
heredoc
double quoted string. with different white spaces"
}
array(2) {
[11]=>
string(90) "11 < 12. 123 >22
'single quoted string'
"double quoted string"
2222 != 1111. 0000 = 0000
"
[12]=>
string(88) "hello
world
1111 != 2222
heredoc
double quoted string. with different white spaces"
}
-- Iteration 9 --
array(2) {
[2]=>
string(3) "two"
[3]=>
string(3) "one"
}
array(2) {
[2]=>
string(3) "two"
[3]=>
string(3) "one"
}
-- Iteration 10 --
array(3) {
[5]=>
int(2)
[7]=>
bool(true)
["two"]=>
int(2)
}
array(3) {
[5]=>
int(2)
[7]=>
bool(true)
["two"]=>
int(2)
}
-- Iteration 11 --
array(0) {
}
array(0) {
}
-- Iteration 12 --
array(1) {
["one"]=>
string(3) "ten"
}
array(1) {
["one"]=>
string(3) "ten"
}
-- Iteration 13 --
array(3) {
[2]=>
string(3) "two"
[4]=>
string(4) "four"
[7]=>
bool(true)
}
array(3) {
[2]=>
string(3) "two"
[4]=>
string(4) "four"
[7]=>
bool(true)
}
-- Iteration 14 --
array(2) {
[8]=>
bool(false)
[13]=>
string(0) ""
}
array(2) {
[8]=>
bool(false)
[13]=>
string(0) ""
}
-- Iteration 15 --
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
string(0) ""
}
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
string(0) ""
}
-- Iteration 16 --
array(3) {
[8]=>
bool(false)
[13]=>
string(0) ""
[""]=>
string(6) "emptys"
}
array(3) {
[8]=>
bool(false)
[13]=>
string(0) ""
[""]=>
string(6) "emptys"
}
-- Iteration 17 --
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
string(0) ""
}
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
string(0) ""
}
-- Iteration 18 --
array(1) {
[0]=>
int(5)
}
array(1) {
[0]=>
int(5)
}
-- Iteration 19 --
array(0) {
}
array(0) {
}
Done
@@ -0,0 +1,214 @@
--TEST--
Test array_intersect() function : usage variations - assoc array with diff keys for 'arr1' argument
--FILE--
<?php
/* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
* Description: Returns the entries of arr1 that have values which are present in all the other arguments
* Source code: ext/standard/array.c
*/
/*
* Testing the functionality of array_intersect() by passing different
* associative arrays having different possible keys to $arr1 argument.
* The $arr2 argument is a fixed array
*/
echo "*** Testing array_intersect() : assoc array with diff keys to \$arr1 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 = <<<EOT
Hello world
EOT;
// different variations of associative arrays to be passed to $arr1 argument
$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
/*7*/ array('\tHello' => 111, 're\td' => "color",
'\v\fworld' => 2.2, 'pen\n' => 33),
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
/*10*/ array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'),
// array with mixed keys
/*11*/ array('hello' => 1, new classA() => 2, "fruit" => 2.2,
$fp => 'resource', 133 => "int", 444.432 => "float",
@$unset_var => "unset", $heredoc => "heredoc")
);
// array to be passsed to $arr2 argument
$arr2 = array(1, "float", "f4", "hello", 2.2, 'color', "string", "pen\n", 11);
// loop through each sub-array within $arrrays to check the behavior of array_intersect()
$iterator = 1;
foreach($arrays as $arr1) {
echo "-- Iterator $iterator --\n";
// Calling array_intersect() with default arguments
var_dump( array_intersect($arr1, $arr2) );
// Calling array_intersect() with more arguments.
// additional argument passed is the same as $arr1 argument
var_dump( array_intersect($arr1, $arr2, $arr1) );
$iterator++;
}
// close the file resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_intersect() : assoc array with diff keys to $arr1 argument ***
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
-- Iterator 1 --
array(0) {
}
array(0) {
}
-- Iterator 2 --
array(0) {
}
array(0) {
}
-- Iterator 3 --
array(1) {
[1]=>
string(1) "1"
}
array(1) {
[1]=>
string(1) "1"
}
-- Iterator 4 --
array(1) {
[1]=>
string(1) "1"
}
array(1) {
[1]=>
string(1) "1"
}
-- Iterator 5 --
array(1) {
[2]=>
string(5) "float"
}
array(1) {
[2]=>
string(5) "float"
}
-- Iterator 6 --
array(1) {
[33333333]=>
string(2) "f4"
}
array(1) {
[33333333]=>
string(2) "f4"
}
-- Iterator 7 --
array(2) {
["re\td"]=>
string(5) "color"
["\v\fworld"]=>
float(2.2)
}
array(2) {
["re\td"]=>
string(5) "color"
["\v\fworld"]=>
float(2.2)
}
-- Iterator 8 --
array(2) {
["re d"]=>
string(5) "color"
[" world"]=>
float(2.2)
}
array(2) {
["re d"]=>
string(5) "color"
[" world"]=>
float(2.2)
}
-- Iterator 9 --
array(2) {
[0]=>
string(5) "hello"
["Hello world"]=>
string(6) "string"
}
array(2) {
[0]=>
string(5) "hello"
["Hello world"]=>
string(6) "string"
}
-- Iterator 10 --
array(1) {
[""]=>
string(5) "hello"
}
array(1) {
[""]=>
string(5) "hello"
}
-- Iterator 11 --
array(3) {
["hello"]=>
int(1)
["fruit"]=>
float(2.2)
[444]=>
string(5) "float"
}
array(3) {
["hello"]=>
int(1)
["fruit"]=>
float(2.2)
[444]=>
string(5) "float"
}
Done
@@ -0,0 +1,214 @@
--TEST--
Test array_intersect() function : usage variations - assoc array with diff keys for 'arr2' argument
--FILE--
<?php
/* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
* Description: Returns the entries of arr1 that have values which are present in all the other arguments
* Source code: ext/standard/array.c
*/
/*
* Testing the functionality of array_intersect() by passing different
* associative arrays having different possible keys to $arr2 argument.
* The $arr1 argument is a fixed array.
*/
echo "*** Testing array_intersect() : assoc array with diff keys to \$arr2 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 = <<<EOT
Hello world
EOT;
// different variations of associative arrays to be passed to $arr2 argument
$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
/*7*/ array('\tHello' => 111, 're\td' => "color",
'\v\fworld' => 2.2, 'pen\n' => 33),
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
/*10*/ array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'),
// array with mixed keys
/*11*/ array('hello' => 1, new classA() => 2, "fruit" => 2.2,
$fp => 'resource', 133 => "int", 444.432 => "float",
@$unset_var => "unset", $heredoc => "heredoc")
);
// array to be passsed to $arr1 argument
$arr1 = array(1, "float", "f4", "hello", 2.2, 'color', "string", "pen\n", 11);
// loop through each sub-array within $arrrays to check the behavior of array_intersect()
$iterator = 1;
foreach($arrays as $arr2) {
echo "-- Iterator $iterator --\n";
// Calling array_intersect() with default arguments
var_dump( array_intersect($arr1, $arr2) );
// Calling array_intersect() with more arguments.
// additional argument passed is the same as $arr1 argument
var_dump( array_intersect($arr1, $arr2, $arr1) );
$iterator++;
}
// close the file resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_intersect() : assoc array with diff keys to $arr2 argument ***
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
-- Iterator 1 --
array(0) {
}
array(0) {
}
-- Iterator 2 --
array(0) {
}
array(0) {
}
-- Iterator 3 --
array(1) {
[0]=>
int(1)
}
array(1) {
[0]=>
int(1)
}
-- Iterator 4 --
array(1) {
[0]=>
int(1)
}
array(1) {
[0]=>
int(1)
}
-- Iterator 5 --
array(1) {
[1]=>
string(5) "float"
}
array(1) {
[1]=>
string(5) "float"
}
-- Iterator 6 --
array(1) {
[2]=>
string(2) "f4"
}
array(1) {
[2]=>
string(2) "f4"
}
-- Iterator 7 --
array(2) {
[4]=>
float(2.2)
[5]=>
string(5) "color"
}
array(2) {
[4]=>
float(2.2)
[5]=>
string(5) "color"
}
-- Iterator 8 --
array(2) {
[4]=>
float(2.2)
[5]=>
string(5) "color"
}
array(2) {
[4]=>
float(2.2)
[5]=>
string(5) "color"
}
-- Iterator 9 --
array(2) {
[3]=>
string(5) "hello"
[6]=>
string(6) "string"
}
array(2) {
[3]=>
string(5) "hello"
[6]=>
string(6) "string"
}
-- Iterator 10 --
array(1) {
[3]=>
string(5) "hello"
}
array(1) {
[3]=>
string(5) "hello"
}
-- Iterator 11 --
array(3) {
[0]=>
int(1)
[1]=>
string(5) "float"
[4]=>
float(2.2)
}
array(3) {
[0]=>
int(1)
[1]=>
string(5) "float"
[4]=>
float(2.2)
}
Done
@@ -0,0 +1,211 @@
--TEST--
Test array_intersect() function : usage variations - assoc array with diff values for 'arr1' argument
--FILE--
<?php
/* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
* Description: Returns the entries of arr1 that have values which are present in all the other arguments
* Source code: ext/standard/array.c
*/
/*
* Testing the functionality of array_intersect() by passing different
* associative arrays having different possible values to $arr1 argument.
* The $arr2 argument is a fixed array
*/
echo "*** Testing array_intersect() : assoc array with diff values to \$arr1 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 = <<<EOT
Hello world
EOT;
// different variations of associative arrays to be passed to $arr1 argument
$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
/*7*/ array(111 => "\tHello", "red" => "col\tor", 2 => "\v\fworld", 3.3 => "pen\n"),
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
/*10*/ 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)
);
// array to be passsed to $arr2 argument
$arr2 = array(1, 2, 1.2, 2.3333, "col\tor", '\v\fworld', $fp,
"Hello world", $heredoc, new classA(), 444.432, "fruit");
// loop through each sub-array within $arrrays to check the behavior of array_intersect()
$iterator = 1;
foreach($arrays as $arr1) {
echo "-- Iterator $iterator --\n";
// Calling array_intersect() with default arguments
var_dump( array_intersect($arr1, $arr2) );
// Calling array_intersect() with more arguments.
// additional argument passed is the same as $arr1 argument
var_dump( array_intersect($arr1, $arr2, $arr1) );
$iterator++;
}
// close the file resource used
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_intersect() : assoc array with diff values to $arr1 argument ***
-- Iterator 1 --
array(0) {
}
array(0) {
}
-- Iterator 2 --
array(0) {
}
array(0) {
}
-- Iterator 3 --
array(1) {
[1]=>
int(1)
}
array(1) {
[1]=>
int(1)
}
-- Iterator 4 --
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
-- Iterator 5 --
array(1) {
["float"]=>
float(2.3333)
}
array(1) {
["float"]=>
float(2.3333)
}
-- Iterator 6 --
array(1) {
["f1"]=>
float(1.2)
}
array(1) {
["f1"]=>
float(1.2)
}
-- Iterator 7 --
array(1) {
["red"]=>
string(6) "col or"
}
array(1) {
["red"]=>
string(6) "col or"
}
-- Iterator 8 --
array(1) {
[2]=>
string(9) "\v\fworld"
}
array(1) {
[2]=>
string(9) "\v\fworld"
}
-- Iterator 9 --
array(1) {
["heredoc"]=>
string(11) "Hello world"
}
array(1) {
["heredoc"]=>
string(11) "Hello world"
}
-- Iterator 10 --
array(2) {
[11]=>
object(classA)#%d (0) {
}
["resource"]=>
resource(%d) of type (stream)
}
array(2) {
[11]=>
object(classA)#%d (0) {
}
["resource"]=>
resource(%d) of type (stream)
}
-- Iterator 11 --
array(5) {
[2]=>
object(classA)#%d (0) {
}
[222]=>
string(5) "fruit"
["resource"]=>
resource(%d) of type (stream)
["float"]=>
float(444.432)
["heredoc"]=>
string(11) "Hello world"
}
array(5) {
[2]=>
object(classA)#%d (0) {
}
[222]=>
string(5) "fruit"
["resource"]=>
resource(%d) of type (stream)
["float"]=>
float(444.432)
["heredoc"]=>
string(11) "Hello world"
}
Done
Loaded 100 of 463 files, more files were not shown because too many files have changed in this diff. Show more