mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
tree: drop non canonical casts and ZPP tests
This commit is contained in:
parent
14034ad734
commit
1e0c8baf05
24 changed files with 75 additions and 1122 deletions
|
@ -5,12 +5,12 @@ zend.assertions=1
|
||||||
assert.exception=1
|
assert.exception=1
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
var_dump((integer)ini_get("zend.assertions"));
|
var_dump((int)ini_get("zend.assertions"));
|
||||||
ini_set("zend.assertions", 0);
|
ini_set("zend.assertions", 0);
|
||||||
var_dump((integer)ini_get("zend.assertions"));
|
var_dump((int)ini_get("zend.assertions"));
|
||||||
assert(false);
|
assert(false);
|
||||||
ini_set("zend.assertions", 1);
|
ini_set("zend.assertions", 1);
|
||||||
var_dump((integer)ini_get("zend.assertions"));
|
var_dump((int)ini_get("zend.assertions"));
|
||||||
assert(true);
|
assert(true);
|
||||||
var_dump(true);
|
var_dump(true);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -5,7 +5,7 @@ precision=14
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$doubles = array(
|
$floats = array(
|
||||||
076545676543223,
|
076545676543223,
|
||||||
032325463734,
|
032325463734,
|
||||||
0777777,
|
0777777,
|
||||||
|
@ -13,8 +13,8 @@ $doubles = array(
|
||||||
033333333333333,
|
033333333333333,
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($doubles as $d) {
|
foreach ($floats as $d) {
|
||||||
$l = (double)$d;
|
$l = (float)$d;
|
||||||
var_dump($l);
|
var_dump($l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ MySQLPDOTest::skip();
|
||||||
test_type($db, 90, 'MEDIUMINT UNSIGNED', 16777215, ($is_mysqlnd) ? 16777215 : '16777215');
|
test_type($db, 90, 'MEDIUMINT UNSIGNED', 16777215, ($is_mysqlnd) ? 16777215 : '16777215');
|
||||||
|
|
||||||
test_type($db, 100, 'INT', -2147483648,
|
test_type($db, 100, 'INT', -2147483648,
|
||||||
($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? (int)-2147483648 : (double)-2147483648) : '-2147483648',
|
($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? (int)-2147483648 : (float)-2147483648) : '-2147483648',
|
||||||
NULL, ($is_mysqlnd) ? 'integer' : NULL);
|
NULL, ($is_mysqlnd) ? 'integer' : NULL);
|
||||||
|
|
||||||
test_type($db, 110, 'INT UNSIGNED', 4294967295, ($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? 4294967295 : '4294967295') : '4294967295');
|
test_type($db, 110, 'INT UNSIGNED', 4294967295, ($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? 4294967295 : '4294967295') : '4294967295');
|
||||||
|
|
|
@ -114,15 +114,15 @@ class Extract_Phar
|
||||||
{
|
{
|
||||||
$fp = fopen(__FILE__, 'rb');
|
$fp = fopen(__FILE__, 'rb');
|
||||||
fseek($fp, self::LEN);
|
fseek($fp, self::LEN);
|
||||||
$L = unpack('V', $a = (binary)fread($fp, 4));
|
$L = unpack('V', $a = (string)fread($fp, 4));
|
||||||
$m = (binary)'';
|
$m = '';
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$read = 8192;
|
$read = 8192;
|
||||||
if ($L[1] - strlen($m) < 8192) {
|
if ($L[1] - strlen($m) < 8192) {
|
||||||
$read = $L[1] - strlen($m);
|
$read = $L[1] - strlen($m);
|
||||||
}
|
}
|
||||||
$last = (binary)fread($fp, $read);
|
$last = (string)fread($fp, $read);
|
||||||
$m .= $last;
|
$m .= $last;
|
||||||
} while (strlen($last) && strlen($m) < $L[1]);
|
} while (strlen($last) && strlen($m) < $L[1]);
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ class Extract_Phar
|
||||||
$entry[0] . ")");
|
$entry[0] . ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
|
if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
|
||||||
die("Invalid internal .phar file (checksum error)");
|
die("Invalid internal .phar file (checksum error)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
$manifest = (binary)'';
|
$manifest = '';
|
||||||
$glags = 0;
|
$glags = 0;
|
||||||
|
|
||||||
foreach($files as $name => $cont)
|
foreach($files as $name => $cont)
|
||||||
|
@ -34,12 +34,12 @@ foreach($files as $name => $cont)
|
||||||
if (empty($comp)) $comp = $cont;
|
if (empty($comp)) $comp = $cont;
|
||||||
if (empty($ulen)) $ulen = strlen($cont);
|
if (empty($ulen)) $ulen = strlen($cont);
|
||||||
if (empty($clen)) $clen = strlen($comp);
|
if (empty($clen)) $clen = strlen($comp);
|
||||||
if (empty($crc32))$crc32= crc32((binary)$cont);
|
if (empty($crc32))$crc32= crc32($cont);
|
||||||
if (isset($meta)) $meta = serialize($meta);
|
if (isset($meta)) $meta = serialize($meta);
|
||||||
|
|
||||||
// write manifest entry
|
// write manifest entry
|
||||||
$manifest .= pack('V', strlen($name)) . (binary)$name;
|
$manifest .= pack('V', strlen($name)) . $name;
|
||||||
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta;
|
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . $meta;
|
||||||
|
|
||||||
// globals
|
// globals
|
||||||
$gflags |= $flags;
|
$gflags |= $flags;
|
||||||
|
@ -50,13 +50,13 @@ if (!isset($alias)) $alias = 'hio';
|
||||||
|
|
||||||
if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
|
if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
|
||||||
|
|
||||||
$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . (binary)$alias . pack('V', strlen($pmeta)) . (binary)$pmeta . $manifest;
|
$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . $alias . pack('V', strlen($pmeta)) . $pmeta . $manifest;
|
||||||
$file = (binary)$file;
|
$file = $file;
|
||||||
$file .= pack('V', strlen($manifest)) . $manifest;
|
$file .= pack('V', strlen($manifest)) . $manifest;
|
||||||
|
|
||||||
foreach($files as $cont)
|
foreach($files as $cont)
|
||||||
{
|
{
|
||||||
$file .= (binary)$cont;
|
$file .= $cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents($fname, $file);
|
file_put_contents($fname, $file);
|
||||||
|
|
|
@ -5,7 +5,7 @@ ini_set('date.timezone', 'GMT');
|
||||||
$tname = basename(current(get_included_files()), ".php");
|
$tname = basename(current(get_included_files()), ".php");
|
||||||
$fname = dirname(__FILE__) . "/$tname.phar.php";
|
$fname = dirname(__FILE__) . "/$tname.phar.php";
|
||||||
$pname = 'phar://' . $fname;
|
$pname = 'phar://' . $fname;
|
||||||
$file = (binary)'<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
|
$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
|
||||||
|
|
||||||
$files = array();
|
$files = array();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
$manifest = (binary)'';
|
$manifest = '';
|
||||||
$gflags = 0;
|
$gflags = 0;
|
||||||
|
|
||||||
foreach($files as $name => $cont)
|
foreach($files as $name => $cont)
|
||||||
|
@ -34,12 +34,12 @@ foreach($files as $name => $cont)
|
||||||
if (empty($comp)) $comp = $cont;
|
if (empty($comp)) $comp = $cont;
|
||||||
if (empty($ulen)) $ulen = strlen($cont);
|
if (empty($ulen)) $ulen = strlen($cont);
|
||||||
if (empty($clen)) $clen = strlen($comp);
|
if (empty($clen)) $clen = strlen($comp);
|
||||||
if (empty($crc32))$crc32= crc32((binary)$cont);
|
if (empty($crc32))$crc32= crc32($cont);
|
||||||
$meta = isset($meta) ? serialize($meta) : "";
|
$meta = isset($meta) ? serialize($meta) : "";
|
||||||
|
|
||||||
// write manifest entry
|
// write manifest entry
|
||||||
$manifest .= pack('V', strlen($name)) . (binary)$name;
|
$manifest .= pack('V', strlen($name)) . $name;
|
||||||
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta;
|
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . $meta;
|
||||||
|
|
||||||
// globals
|
// globals
|
||||||
$gflags |= $flags;
|
$gflags |= $flags;
|
||||||
|
@ -50,13 +50,13 @@ if (!isset($alias)) $alias = 'hio';
|
||||||
|
|
||||||
if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
|
if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
|
||||||
|
|
||||||
$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . (binary)$alias . pack('V', strlen($pmeta)) . (binary)$pmeta . $manifest;
|
$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . $alias . pack('V', strlen($pmeta)) . $pmeta . $manifest;
|
||||||
$file = (binary)$file;
|
$file = $file;
|
||||||
$file .= pack('V', strlen($manifest)) . $manifest;
|
$file .= pack('V', strlen($manifest)) . $manifest;
|
||||||
|
|
||||||
foreach($files as $cont)
|
foreach($files as $cont)
|
||||||
{
|
{
|
||||||
$file .= (binary)$cont;
|
$file .= $cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents($fname, $file);
|
file_put_contents($fname, $file);
|
||||||
|
|
|
@ -108,16 +108,16 @@ class danger_tarmaker
|
||||||
|
|
||||||
$checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
|
$checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
|
||||||
|
|
||||||
fwrite($this->tmp, (binary)$block . $checksum . $blockend, 512);
|
fwrite($this->tmp, $block . $checksum . $blockend, 512);
|
||||||
if (is_resource($fileOrStream)) {
|
if (is_resource($fileOrStream)) {
|
||||||
stream_copy_to_stream($fileOrStream, $this->tmp);
|
stream_copy_to_stream($fileOrStream, $this->tmp);
|
||||||
if ($stat['size'] % 512) {
|
if ($stat['size'] % 512) {
|
||||||
fwrite($this->tmp, (binary)str_repeat("\0", 512 - $stat['size'] % 512));
|
fwrite($this->tmp, str_repeat("\0", 512 - $stat['size'] % 512));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fwrite($this->tmp, (binary)$fileOrStream);
|
fwrite($this->tmp, $fileOrStream);
|
||||||
if (strlen($fileOrStream) % 512) {
|
if (strlen($fileOrStream) % 512) {
|
||||||
fwrite($this->tmp, (binary)str_repeat("\0", 512 - strlen($fileOrStream) % 512));
|
fwrite($this->tmp, str_repeat("\0", 512 - strlen($fileOrStream) % 512));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ include dirname(__FILE__) . '/tarmaker.php.inc';
|
||||||
class corrupter extends tarmaker {
|
class corrupter extends tarmaker {
|
||||||
function close()
|
function close()
|
||||||
{
|
{
|
||||||
fwrite($this->tmp, (binary)'oopsie');
|
fwrite($this->tmp, 'oopsie');
|
||||||
fclose($this->tmp);
|
fclose($this->tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,16 +107,16 @@ class tarmaker
|
||||||
|
|
||||||
$checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
|
$checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
|
||||||
|
|
||||||
fwrite($this->tmp, (binary)$block . $checksum . $blockend, 512);
|
fwrite($this->tmp, $block . $checksum . $blockend, 512);
|
||||||
if (is_resource($fileOrStream)) {
|
if (is_resource($fileOrStream)) {
|
||||||
stream_copy_to_stream($fileOrStream, $this->tmp);
|
stream_copy_to_stream($fileOrStream, $this->tmp);
|
||||||
if ($stat['size'] % 512) {
|
if ($stat['size'] % 512) {
|
||||||
fwrite($this->tmp, (binary)str_repeat("\0", 512 - $stat['size'] % 512));
|
fwrite($this->tmp, str_repeat("\0", 512 - $stat['size'] % 512));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fwrite($this->tmp, (binary)$fileOrStream);
|
fwrite($this->tmp, $fileOrStream);
|
||||||
if (strlen($fileOrStream) % 512) {
|
if (strlen($fileOrStream) % 512) {
|
||||||
fwrite($this->tmp, (binary)str_repeat("\0", 512 - strlen($fileOrStream) % 512));
|
fwrite($this->tmp, str_repeat("\0", 512 - strlen($fileOrStream) % 512));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ var_dump((bool)$foo);
|
||||||
var_dump((bool)$people);
|
var_dump((bool)$people);
|
||||||
var_dump((int)$foo);
|
var_dump((int)$foo);
|
||||||
var_dump((int)$people);
|
var_dump((int)$people);
|
||||||
var_dump((double)$foo);
|
var_dump((float)$foo);
|
||||||
var_dump((double)$people);
|
var_dump((float)$people);
|
||||||
var_dump((string)$foo);
|
var_dump((string)$foo);
|
||||||
var_dump((string)$people);
|
var_dump((string)$people);
|
||||||
var_dump((array)$foo);
|
var_dump((array)$foo);
|
||||||
|
|
|
@ -11,8 +11,8 @@ var_dump($xml->number);
|
||||||
$int = $xml->number / 1024 / 1024 / 1024;
|
$int = $xml->number / 1024 / 1024 / 1024;
|
||||||
var_dump($int);
|
var_dump($int);
|
||||||
|
|
||||||
$double = (double) $xml->number / 1024 / 1024 / 1024;
|
$float = (float) $xml->number / 1024 / 1024 / 1024;
|
||||||
var_dump($double);
|
var_dump($float);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
object(SimpleXMLElement)#2 (1) {
|
object(SimpleXMLElement)#2 (1) {
|
||||||
|
|
|
@ -1,114 +0,0 @@
|
||||||
--TEST--
|
|
||||||
SPL: RecursiveTreeIterator and binary vs unicode (PHP 6.0+)
|
|
||||||
--INI--
|
|
||||||
error_reporting=E_ALL&~E_NOTICE
|
|
||||||
--FILE--
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$ary = array(
|
|
||||||
0 => array(
|
|
||||||
(binary) "binary",
|
|
||||||
"abc2",
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
(binary) "binary" => array(
|
|
||||||
2,
|
|
||||||
"b",
|
|
||||||
3 => array(
|
|
||||||
4,
|
|
||||||
"c",
|
|
||||||
),
|
|
||||||
"4abc" => array(
|
|
||||||
4,
|
|
||||||
"c",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$it = new RecursiveTreeIterator(new RecursiveArrayIterator($ary), 0);
|
|
||||||
foreach($it as $k => $v) {
|
|
||||||
var_dump($v);
|
|
||||||
}
|
|
||||||
echo "\n----------------\n\n";
|
|
||||||
foreach($it as $k => $v) {
|
|
||||||
var_dump($k);
|
|
||||||
}
|
|
||||||
echo "\n----------------\n\n";
|
|
||||||
echo "key, getEntry, current:\n";
|
|
||||||
foreach($it as $k => $v) {
|
|
||||||
var_dump($it->key(), $it->getEntry(), $it->current());
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
--EXPECT--
|
|
||||||
string(7) "|-Array"
|
|
||||||
string(10) "| |-binary"
|
|
||||||
string(8) "| |-abc2"
|
|
||||||
string(5) "| \-1"
|
|
||||||
string(7) "\-Array"
|
|
||||||
string(5) " |-2"
|
|
||||||
string(5) " |-b"
|
|
||||||
string(9) " |-Array"
|
|
||||||
string(7) " | |-4"
|
|
||||||
string(7) " | \-c"
|
|
||||||
string(9) " \-Array"
|
|
||||||
string(7) " |-4"
|
|
||||||
string(7) " \-c"
|
|
||||||
|
|
||||||
----------------
|
|
||||||
|
|
||||||
string(3) "|-0"
|
|
||||||
string(5) "| |-0"
|
|
||||||
string(5) "| |-1"
|
|
||||||
string(5) "| \-2"
|
|
||||||
string(8) "\-binary"
|
|
||||||
string(5) " |-0"
|
|
||||||
string(5) " |-1"
|
|
||||||
string(5) " |-3"
|
|
||||||
string(7) " | |-0"
|
|
||||||
string(7) " | \-1"
|
|
||||||
string(8) " \-4abc"
|
|
||||||
string(7) " |-0"
|
|
||||||
string(7) " \-1"
|
|
||||||
|
|
||||||
----------------
|
|
||||||
|
|
||||||
key, getEntry, current:
|
|
||||||
string(3) "|-0"
|
|
||||||
string(5) "Array"
|
|
||||||
string(7) "|-Array"
|
|
||||||
string(5) "| |-0"
|
|
||||||
string(6) "binary"
|
|
||||||
string(10) "| |-binary"
|
|
||||||
string(5) "| |-1"
|
|
||||||
string(4) "abc2"
|
|
||||||
string(8) "| |-abc2"
|
|
||||||
string(5) "| \-2"
|
|
||||||
string(1) "1"
|
|
||||||
string(5) "| \-1"
|
|
||||||
string(8) "\-binary"
|
|
||||||
string(5) "Array"
|
|
||||||
string(7) "\-Array"
|
|
||||||
string(5) " |-0"
|
|
||||||
string(1) "2"
|
|
||||||
string(5) " |-2"
|
|
||||||
string(5) " |-1"
|
|
||||||
string(1) "b"
|
|
||||||
string(5) " |-b"
|
|
||||||
string(5) " |-3"
|
|
||||||
string(5) "Array"
|
|
||||||
string(9) " |-Array"
|
|
||||||
string(7) " | |-0"
|
|
||||||
string(1) "4"
|
|
||||||
string(7) " | |-4"
|
|
||||||
string(7) " | \-1"
|
|
||||||
string(1) "c"
|
|
||||||
string(7) " | \-c"
|
|
||||||
string(8) " \-4abc"
|
|
||||||
string(5) "Array"
|
|
||||||
string(9) " \-Array"
|
|
||||||
string(7) " |-0"
|
|
||||||
string(1) "4"
|
|
||||||
string(7) " |-4"
|
|
||||||
string(7) " \-1"
|
|
||||||
string(1) "c"
|
|
||||||
string(7) " \-c"
|
|
|
@ -1,179 +0,0 @@
|
||||||
--TEST--
|
|
||||||
Test array_diff_assoc() function : usage variations - unexpected values for 'array1' argument
|
|
||||||
--FILE--
|
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Pass array_diff_assoc arguments that are not arrays in place of $array1
|
|
||||||
*/
|
|
||||||
|
|
||||||
echo "*** Testing array_diff_assoc() : usage variations ***\n";
|
|
||||||
|
|
||||||
$array = array(1, 2, 3);
|
|
||||||
|
|
||||||
//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");
|
|
||||||
|
|
||||||
//array of unexpected values to be passed to $array1 argument
|
|
||||||
$inputs = 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,
|
|
||||||
|
|
||||||
// binary data
|
|
||||||
/*21*/ b"binary",
|
|
||||||
(binary)"binary",
|
|
||||||
|
|
||||||
// object data
|
|
||||||
/*23*/ new classA(),
|
|
||||||
|
|
||||||
// undefined data
|
|
||||||
/*24*/ @$undefined_var,
|
|
||||||
|
|
||||||
// unset data
|
|
||||||
/*25*/ @$unset_var,
|
|
||||||
|
|
||||||
// resource variable
|
|
||||||
/*26*/ $fp,
|
|
||||||
);
|
|
||||||
|
|
||||||
// loop through each element of $inputs to check the behavior of array_diff_assoc
|
|
||||||
$iterator = 1;
|
|
||||||
foreach($inputs as $input) {
|
|
||||||
echo "\n-- Iteration $iterator --\n";
|
|
||||||
try {
|
|
||||||
var_dump(array_diff_assoc($input, $array));
|
|
||||||
} catch (TypeError $e) {
|
|
||||||
echo $e->getMessage(), "\n";
|
|
||||||
}
|
|
||||||
$iterator++;
|
|
||||||
};
|
|
||||||
fclose($fp);
|
|
||||||
echo "Done";
|
|
||||||
?>
|
|
||||||
--EXPECT--
|
|
||||||
*** Testing array_diff_assoc() : usage variations ***
|
|
||||||
|
|
||||||
-- Iteration 1 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 2 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 3 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 4 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 5 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 6 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 7 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 8 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 9 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 10 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 11 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 12 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, true given
|
|
||||||
|
|
||||||
-- Iteration 13 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, false given
|
|
||||||
|
|
||||||
-- Iteration 14 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, true given
|
|
||||||
|
|
||||||
-- Iteration 15 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, false given
|
|
||||||
|
|
||||||
-- Iteration 16 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 17 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 18 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 19 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 20 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 21 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 22 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 23 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, classA given
|
|
||||||
|
|
||||||
-- Iteration 24 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 25 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 26 --
|
|
||||||
array_diff_assoc(): Argument #1 ($array) must be of type array, resource given
|
|
||||||
Done
|
|
|
@ -1,179 +0,0 @@
|
||||||
--TEST--
|
|
||||||
Test array_diff_assoc() function : usage variations - unexpected values for 'array1' argument
|
|
||||||
--FILE--
|
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* pass array_diff_assoc arguments which are not arrays in place of $array2
|
|
||||||
*/
|
|
||||||
|
|
||||||
echo "\n*** Testing array_diff_assoc() : usage variations ***\n";
|
|
||||||
|
|
||||||
$array = array(1, 2, 3);
|
|
||||||
|
|
||||||
//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");
|
|
||||||
|
|
||||||
//array of unexpected values to be passed to $array1 argument
|
|
||||||
$inputs = 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,
|
|
||||||
|
|
||||||
// binary data
|
|
||||||
/*21*/ b"binary",
|
|
||||||
(binary)"binary",
|
|
||||||
|
|
||||||
// object data
|
|
||||||
/*23*/ new classA(),
|
|
||||||
|
|
||||||
// undefined data
|
|
||||||
/*24*/ @$undefined_var,
|
|
||||||
|
|
||||||
// unset data
|
|
||||||
/*25*/ @$unset_var,
|
|
||||||
|
|
||||||
// resource variable
|
|
||||||
/*26*/ $fp,
|
|
||||||
);
|
|
||||||
|
|
||||||
// loop through each element of $inputs to check the behavior of array_diff_assoc
|
|
||||||
$iterator = 1;
|
|
||||||
foreach($inputs as $input) {
|
|
||||||
echo "\n-- Iteration $iterator --\n";
|
|
||||||
try {
|
|
||||||
var_dump(array_diff_assoc($array, $input));
|
|
||||||
} catch (TypeError $e) {
|
|
||||||
echo $e->getMessage(), "\n";
|
|
||||||
}
|
|
||||||
$iterator++;
|
|
||||||
};
|
|
||||||
fclose($fp);
|
|
||||||
echo "Done";
|
|
||||||
?>
|
|
||||||
--EXPECT--
|
|
||||||
*** Testing array_diff_assoc() : usage variations ***
|
|
||||||
|
|
||||||
-- Iteration 1 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 2 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 3 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 4 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 5 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 6 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 7 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 8 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 9 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 10 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 11 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 12 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, true given
|
|
||||||
|
|
||||||
-- Iteration 13 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, false given
|
|
||||||
|
|
||||||
-- Iteration 14 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, true given
|
|
||||||
|
|
||||||
-- Iteration 15 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, false given
|
|
||||||
|
|
||||||
-- Iteration 16 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 17 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 18 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 19 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 20 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 21 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 22 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 23 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, classA given
|
|
||||||
|
|
||||||
-- Iteration 24 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 25 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 26 --
|
|
||||||
array_diff_assoc(): Argument #2 must be of type array, resource given
|
|
||||||
Done
|
|
|
@ -10,10 +10,6 @@ echo "\n*** Testing array_diff_assoc() : usage variations ***\n";
|
||||||
|
|
||||||
$array = array(1, 2, 3);
|
$array = array(1, 2, 3);
|
||||||
|
|
||||||
//get an unset variable
|
|
||||||
$unset_var = 10;
|
|
||||||
unset ($unset_var);
|
|
||||||
|
|
||||||
// get a class
|
// get a class
|
||||||
class classA
|
class classA
|
||||||
{
|
{
|
||||||
|
@ -22,11 +18,6 @@ class classA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// heredoc string
|
|
||||||
$heredoc = <<<EOT
|
|
||||||
hello world
|
|
||||||
EOT;
|
|
||||||
|
|
||||||
//array of different data types to be passed to $arr1 argument
|
//array of different data types to be passed to $arr1 argument
|
||||||
$inputs = array(
|
$inputs = array(
|
||||||
|
|
||||||
|
@ -50,50 +41,28 @@ $inputs = array(
|
||||||
// null data
|
// null data
|
||||||
/*3*/
|
/*3*/
|
||||||
'null' => array(
|
'null' => array(
|
||||||
NULL,
|
|
||||||
null),
|
null),
|
||||||
|
|
||||||
// boolean data
|
// boolean data
|
||||||
/*4*/
|
/*4*/
|
||||||
'bool' => array(
|
'bool' => array(
|
||||||
true,
|
true,
|
||||||
false,
|
false),
|
||||||
TRUE,
|
|
||||||
FALSE),
|
|
||||||
|
|
||||||
// empty data
|
// empty data
|
||||||
/*5*/
|
/*5*/
|
||||||
'empty' => array(
|
'empty' => array(
|
||||||
"",
|
|
||||||
''),
|
''),
|
||||||
|
|
||||||
// string data
|
// string data
|
||||||
/*6*/
|
/*6*/
|
||||||
'string' => array(
|
'string' => array(
|
||||||
"string",
|
'string'),
|
||||||
'string',
|
|
||||||
$heredoc),
|
|
||||||
|
|
||||||
// binary data
|
|
||||||
/*7*/
|
|
||||||
'binary' => array(
|
|
||||||
b"binary",
|
|
||||||
(binary)"binary"),
|
|
||||||
|
|
||||||
// object data
|
// object data
|
||||||
/*8*/
|
/*8*/
|
||||||
'object' => array(
|
'object' => array(
|
||||||
new classA()),
|
new classA()),
|
||||||
|
|
||||||
// undefined data
|
|
||||||
/*9*/
|
|
||||||
'undefined' => array(
|
|
||||||
@$undefined_var),
|
|
||||||
|
|
||||||
// unset data
|
|
||||||
/*10*/
|
|
||||||
'unset' => array(
|
|
||||||
@$unset_var),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// loop through each element of $inputs to check the behavior of array_diff_assoc
|
// loop through each element of $inputs to check the behavior of array_diff_assoc
|
||||||
|
@ -135,65 +104,33 @@ array(5) {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Iteration 3 --
|
-- Iteration 3 --
|
||||||
array(2) {
|
array(1) {
|
||||||
[0]=>
|
[0]=>
|
||||||
NULL
|
NULL
|
||||||
[1]=>
|
|
||||||
NULL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Iteration 4 --
|
-- Iteration 4 --
|
||||||
array(3) {
|
array(1) {
|
||||||
[1]=>
|
[1]=>
|
||||||
bool(false)
|
bool(false)
|
||||||
[2]=>
|
|
||||||
bool(true)
|
|
||||||
[3]=>
|
|
||||||
bool(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Iteration 5 --
|
-- Iteration 5 --
|
||||||
array(2) {
|
array(1) {
|
||||||
[0]=>
|
[0]=>
|
||||||
string(0) ""
|
string(0) ""
|
||||||
[1]=>
|
|
||||||
string(0) ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Iteration 6 --
|
-- Iteration 6 --
|
||||||
array(3) {
|
array(1) {
|
||||||
[0]=>
|
[0]=>
|
||||||
string(6) "string"
|
string(6) "string"
|
||||||
[1]=>
|
|
||||||
string(6) "string"
|
|
||||||
[2]=>
|
|
||||||
string(11) "hello world"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Iteration 7 --
|
-- Iteration 7 --
|
||||||
array(2) {
|
|
||||||
[0]=>
|
|
||||||
string(6) "binary"
|
|
||||||
[1]=>
|
|
||||||
string(6) "binary"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Iteration 8 --
|
|
||||||
array(1) {
|
array(1) {
|
||||||
[0]=>
|
[0]=>
|
||||||
object(classA)#%d (0) {
|
object(classA)#%d (0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Iteration 9 --
|
|
||||||
array(1) {
|
|
||||||
[0]=>
|
|
||||||
NULL
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Iteration 10 --
|
|
||||||
array(1) {
|
|
||||||
[0]=>
|
|
||||||
NULL
|
|
||||||
}
|
|
||||||
Done
|
Done
|
||||||
|
|
|
@ -11,15 +11,6 @@ echo "\n*** Testing array_diff_assoc() : usage variations ***\n";
|
||||||
|
|
||||||
$array = array(1, 2, 3);
|
$array = array(1, 2, 3);
|
||||||
|
|
||||||
//get an unset variable
|
|
||||||
$unset_var = 10;
|
|
||||||
unset ($unset_var);
|
|
||||||
|
|
||||||
// heredoc string
|
|
||||||
$heredoc = <<<EOT
|
|
||||||
hello world
|
|
||||||
EOT;
|
|
||||||
|
|
||||||
//Different data types as keys to be passed to $arr1 argument
|
//Different data types as keys to be passed to $arr1 argument
|
||||||
$inputs = array(
|
$inputs = array(
|
||||||
|
|
||||||
|
@ -31,48 +22,15 @@ $inputs = array(
|
||||||
12345 => 'positive',
|
12345 => 'positive',
|
||||||
-2345 => 'negative'),
|
-2345 => 'negative'),
|
||||||
|
|
||||||
// null data
|
|
||||||
/*3*/
|
|
||||||
'null' => array(
|
|
||||||
NULL => 'null 1',
|
|
||||||
null => 'null 2'),
|
|
||||||
|
|
||||||
// boolean data
|
|
||||||
/*4*/
|
|
||||||
'bool' => array(
|
|
||||||
true => 'boolt',
|
|
||||||
false => 'boolf',
|
|
||||||
TRUE => 'boolT',
|
|
||||||
FALSE => 'boolF'),
|
|
||||||
|
|
||||||
// empty data
|
// empty data
|
||||||
/*5*/
|
/*5*/
|
||||||
'empty' => array(
|
'empty' => array(
|
||||||
"" => 'emptyd',
|
'' => 'empty'),
|
||||||
'' => 'emptys'),
|
|
||||||
|
|
||||||
// string data
|
// string data
|
||||||
/*6*/
|
/*6*/
|
||||||
'string' => array(
|
'string' => array(
|
||||||
"string" => 'stringd',
|
'string' => 'strings'),
|
||||||
'string' => 'strings',
|
|
||||||
$heredoc => 'stringh'),
|
|
||||||
|
|
||||||
// binary data
|
|
||||||
/*7*/
|
|
||||||
'binary' => array(
|
|
||||||
b"binary1" => 'binary 1',
|
|
||||||
(binary)"binary2" => 'binary 2'),
|
|
||||||
|
|
||||||
// undefined data
|
|
||||||
/*8*/
|
|
||||||
'undefined' => array(
|
|
||||||
@$undefined_var => 'undefined'),
|
|
||||||
|
|
||||||
// unset data
|
|
||||||
/*9*/
|
|
||||||
'unset' => array(
|
|
||||||
@$unset_var => 'unset'),
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -104,48 +62,12 @@ array(4) {
|
||||||
-- Iteration 2 --
|
-- Iteration 2 --
|
||||||
array(1) {
|
array(1) {
|
||||||
[""]=>
|
[""]=>
|
||||||
string(6) "null 2"
|
string(5) "empty"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Iteration 3 --
|
-- Iteration 3 --
|
||||||
array(2) {
|
|
||||||
[1]=>
|
|
||||||
string(5) "boolT"
|
|
||||||
[0]=>
|
|
||||||
string(5) "boolF"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Iteration 4 --
|
|
||||||
array(1) {
|
array(1) {
|
||||||
[""]=>
|
|
||||||
string(6) "emptys"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Iteration 5 --
|
|
||||||
array(2) {
|
|
||||||
["string"]=>
|
["string"]=>
|
||||||
string(7) "strings"
|
string(7) "strings"
|
||||||
["hello world"]=>
|
|
||||||
string(7) "stringh"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Iteration 6 --
|
|
||||||
array(2) {
|
|
||||||
["binary1"]=>
|
|
||||||
string(8) "binary 1"
|
|
||||||
["binary2"]=>
|
|
||||||
string(8) "binary 2"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Iteration 7 --
|
|
||||||
array(1) {
|
|
||||||
[""]=>
|
|
||||||
string(9) "undefined"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Iteration 8 --
|
|
||||||
array(1) {
|
|
||||||
[""]=>
|
|
||||||
string(5) "unset"
|
|
||||||
}
|
}
|
||||||
Done
|
Done
|
||||||
|
|
|
@ -1,154 +0,0 @@
|
||||||
--TEST--
|
|
||||||
Test array_diff() function : usage variations - unexpected values for 'array1' argument
|
|
||||||
--FILE--
|
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Test array_diff by passing non array values in place of $array1
|
|
||||||
*/
|
|
||||||
|
|
||||||
echo "*** Testing array_diff() : usage variations ***\n";
|
|
||||||
|
|
||||||
$array = array(1, 2, 3);
|
|
||||||
|
|
||||||
//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 $input argument
|
|
||||||
$inputs = 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,
|
|
||||||
|
|
||||||
// binary data
|
|
||||||
/*21*/ b"binary",
|
|
||||||
(binary)"binary",
|
|
||||||
|
|
||||||
// object data
|
|
||||||
/*23*/ new classA(),
|
|
||||||
|
|
||||||
// undefined data
|
|
||||||
/*24*/ @$undefined_var,
|
|
||||||
|
|
||||||
// unset data
|
|
||||||
/*25*/ @$unset_var,
|
|
||||||
|
|
||||||
// resource variable
|
|
||||||
/*26*/ $fp
|
|
||||||
);
|
|
||||||
|
|
||||||
// loop through each element of $inputs to check the behavior of array_diff
|
|
||||||
$iterator = 1;
|
|
||||||
foreach($inputs as $input) {
|
|
||||||
echo "\n-- Iteration $iterator --";
|
|
||||||
try {
|
|
||||||
var_dump( array_diff($input, $array));
|
|
||||||
} catch (TypeError $e) {
|
|
||||||
echo $e->getMessage(), "\n";
|
|
||||||
}
|
|
||||||
$iterator++;
|
|
||||||
};
|
|
||||||
|
|
||||||
fclose($fp);
|
|
||||||
echo "Done";
|
|
||||||
?>
|
|
||||||
--EXPECT--
|
|
||||||
*** Testing array_diff() : usage variations ***
|
|
||||||
|
|
||||||
-- Iteration 1 --array_diff(): Argument #1 ($array) must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 2 --array_diff(): Argument #1 ($array) must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 3 --array_diff(): Argument #1 ($array) must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 4 --array_diff(): Argument #1 ($array) must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 5 --array_diff(): Argument #1 ($array) must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 6 --array_diff(): Argument #1 ($array) must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 7 --array_diff(): Argument #1 ($array) must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 8 --array_diff(): Argument #1 ($array) must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 9 --array_diff(): Argument #1 ($array) must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 10 --array_diff(): Argument #1 ($array) must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 11 --array_diff(): Argument #1 ($array) must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 12 --array_diff(): Argument #1 ($array) must be of type array, true given
|
|
||||||
|
|
||||||
-- Iteration 13 --array_diff(): Argument #1 ($array) must be of type array, false given
|
|
||||||
|
|
||||||
-- Iteration 14 --array_diff(): Argument #1 ($array) must be of type array, true given
|
|
||||||
|
|
||||||
-- Iteration 15 --array_diff(): Argument #1 ($array) must be of type array, false given
|
|
||||||
|
|
||||||
-- Iteration 16 --array_diff(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 17 --array_diff(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 18 --array_diff(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 19 --array_diff(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 20 --array_diff(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 21 --array_diff(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 22 --array_diff(): Argument #1 ($array) must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 23 --array_diff(): Argument #1 ($array) must be of type array, classA given
|
|
||||||
|
|
||||||
-- Iteration 24 --array_diff(): Argument #1 ($array) must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 25 --array_diff(): Argument #1 ($array) must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 26 --array_diff(): Argument #1 ($array) must be of type array, resource given
|
|
||||||
Done
|
|
|
@ -1,153 +0,0 @@
|
||||||
--TEST--
|
|
||||||
Test array_diff() function : usage variations - unexpected values for 'array2' argument
|
|
||||||
--FILE--
|
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Test array_diff by passing non array values in place of $array2
|
|
||||||
*/
|
|
||||||
|
|
||||||
echo "*** Testing array_diff() : usage variations ***\n";
|
|
||||||
|
|
||||||
$array = array(1, 2, 3);
|
|
||||||
|
|
||||||
//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 $input argument
|
|
||||||
$inputs = 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,
|
|
||||||
|
|
||||||
// binary data
|
|
||||||
/*21*/ b"binary",
|
|
||||||
(binary)"binary",
|
|
||||||
|
|
||||||
// object data
|
|
||||||
/*23*/ new classA(),
|
|
||||||
|
|
||||||
// undefined data
|
|
||||||
/*24*/ @$undefined_var,
|
|
||||||
|
|
||||||
// unset data
|
|
||||||
/*25*/ @$unset_var,
|
|
||||||
|
|
||||||
// resource variable
|
|
||||||
/*26*/ $fp
|
|
||||||
);
|
|
||||||
|
|
||||||
// loop through each element of $inputs to check the behavior of array_diff
|
|
||||||
$iterator = 1;
|
|
||||||
foreach($inputs as $input) {
|
|
||||||
echo "\n-- Iteration $iterator --";
|
|
||||||
try {
|
|
||||||
var_dump( array_diff($array, $input));
|
|
||||||
} catch (TypeError $e) {
|
|
||||||
echo $e->getMessage(), "\n";
|
|
||||||
}
|
|
||||||
$iterator++;
|
|
||||||
};
|
|
||||||
fclose($fp);
|
|
||||||
echo "Done";
|
|
||||||
?>
|
|
||||||
--EXPECT--
|
|
||||||
*** Testing array_diff() : usage variations ***
|
|
||||||
|
|
||||||
-- Iteration 1 --array_diff(): Argument #2 must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 2 --array_diff(): Argument #2 must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 3 --array_diff(): Argument #2 must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 4 --array_diff(): Argument #2 must be of type array, int given
|
|
||||||
|
|
||||||
-- Iteration 5 --array_diff(): Argument #2 must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 6 --array_diff(): Argument #2 must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 7 --array_diff(): Argument #2 must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 8 --array_diff(): Argument #2 must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 9 --array_diff(): Argument #2 must be of type array, float given
|
|
||||||
|
|
||||||
-- Iteration 10 --array_diff(): Argument #2 must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 11 --array_diff(): Argument #2 must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 12 --array_diff(): Argument #2 must be of type array, true given
|
|
||||||
|
|
||||||
-- Iteration 13 --array_diff(): Argument #2 must be of type array, false given
|
|
||||||
|
|
||||||
-- Iteration 14 --array_diff(): Argument #2 must be of type array, true given
|
|
||||||
|
|
||||||
-- Iteration 15 --array_diff(): Argument #2 must be of type array, false given
|
|
||||||
|
|
||||||
-- Iteration 16 --array_diff(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 17 --array_diff(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 18 --array_diff(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 19 --array_diff(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 20 --array_diff(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 21 --array_diff(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 22 --array_diff(): Argument #2 must be of type array, string given
|
|
||||||
|
|
||||||
-- Iteration 23 --array_diff(): Argument #2 must be of type array, classA given
|
|
||||||
|
|
||||||
-- Iteration 24 --array_diff(): Argument #2 must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 25 --array_diff(): Argument #2 must be of type array, null given
|
|
||||||
|
|
||||||
-- Iteration 26 --array_diff(): Argument #2 must be of type array, resource given
|
|
||||||
Done
|
|
|
@ -12,15 +12,6 @@ echo "*** Testing array_diff() : usage variations ***\n";
|
||||||
// Initialise function arguments not being substituted (if any)
|
// Initialise function arguments not being substituted (if any)
|
||||||
$array = array(1, 2);
|
$array = array(1, 2);
|
||||||
|
|
||||||
//get an unset variable
|
|
||||||
$unset_var = 10;
|
|
||||||
unset ($unset_var);
|
|
||||||
|
|
||||||
//get heredoc
|
|
||||||
$heredoc = <<<END
|
|
||||||
This is a heredoc
|
|
||||||
END;
|
|
||||||
|
|
||||||
//array of values to iterate over
|
//array of values to iterate over
|
||||||
$values = array(
|
$values = array(
|
||||||
|
|
||||||
|
@ -46,51 +37,25 @@ $values = array(
|
||||||
/*4*/
|
/*4*/
|
||||||
"null" => array(
|
"null" => array(
|
||||||
// null data
|
// null data
|
||||||
NULL,
|
|
||||||
null),
|
null),
|
||||||
|
|
||||||
/*5*/
|
/*5*/
|
||||||
"boolean" => array(
|
"boolean" => array(
|
||||||
// boolean data
|
// boolean data
|
||||||
true,
|
true,
|
||||||
false,
|
false),
|
||||||
TRUE,
|
|
||||||
FALSE),
|
|
||||||
|
|
||||||
/*6*/
|
/*6*/
|
||||||
"empty" => array(
|
"empty" => array(''),
|
||||||
// empty data
|
|
||||||
"",
|
|
||||||
''),
|
|
||||||
|
|
||||||
/*7*/
|
/*7*/
|
||||||
"string" => array(
|
"string" => array('string'),
|
||||||
// string data
|
|
||||||
"string",
|
|
||||||
'string',
|
|
||||||
$heredoc),
|
|
||||||
|
|
||||||
/*8*/
|
|
||||||
"binary" => array(
|
|
||||||
// binary data
|
|
||||||
b"binary",
|
|
||||||
(binary)"binary"),
|
|
||||||
|
|
||||||
/*9*/
|
|
||||||
"undefined" => array(
|
|
||||||
// undefined data
|
|
||||||
@$undefined_var),
|
|
||||||
|
|
||||||
/*10*/
|
|
||||||
"unset" => array(
|
|
||||||
// unset data
|
|
||||||
@$unset_var)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// loop through each element of the array for arr1
|
// loop through each element of the array for arr1
|
||||||
$iterator = 1;
|
$iterator = 1;
|
||||||
foreach($values as $value) {
|
foreach($values as $value) {
|
||||||
echo "\n Iteration: $iterator \n";
|
echo "Iteration: $iterator\n";
|
||||||
var_dump( array_diff($value, $array) );
|
var_dump( array_diff($value, $array) );
|
||||||
$iterator++;
|
$iterator++;
|
||||||
};
|
};
|
||||||
|
@ -99,12 +64,10 @@ echo "Done";
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
*** Testing array_diff() : usage variations ***
|
*** Testing array_diff() : usage variations ***
|
||||||
|
Iteration: 1
|
||||||
Iteration: 1
|
|
||||||
array(0) {
|
array(0) {
|
||||||
}
|
}
|
||||||
|
Iteration: 2
|
||||||
Iteration: 2
|
|
||||||
array(3) {
|
array(3) {
|
||||||
[0]=>
|
[0]=>
|
||||||
int(0)
|
int(0)
|
||||||
|
@ -113,8 +76,7 @@ array(3) {
|
||||||
[3]=>
|
[3]=>
|
||||||
int(-2345)
|
int(-2345)
|
||||||
}
|
}
|
||||||
|
Iteration: 3
|
||||||
Iteration: 3
|
|
||||||
array(5) {
|
array(5) {
|
||||||
[0]=>
|
[0]=>
|
||||||
float(10.5)
|
float(10.5)
|
||||||
|
@ -127,58 +89,24 @@ array(5) {
|
||||||
[4]=>
|
[4]=>
|
||||||
float(0.5)
|
float(0.5)
|
||||||
}
|
}
|
||||||
|
Iteration: 4
|
||||||
Iteration: 4
|
|
||||||
array(2) {
|
|
||||||
[0]=>
|
|
||||||
NULL
|
|
||||||
[1]=>
|
|
||||||
NULL
|
|
||||||
}
|
|
||||||
|
|
||||||
Iteration: 5
|
|
||||||
array(2) {
|
|
||||||
[1]=>
|
|
||||||
bool(false)
|
|
||||||
[3]=>
|
|
||||||
bool(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
Iteration: 6
|
|
||||||
array(2) {
|
|
||||||
[0]=>
|
|
||||||
string(0) ""
|
|
||||||
[1]=>
|
|
||||||
string(0) ""
|
|
||||||
}
|
|
||||||
|
|
||||||
Iteration: 7
|
|
||||||
array(3) {
|
|
||||||
[0]=>
|
|
||||||
string(6) "string"
|
|
||||||
[1]=>
|
|
||||||
string(6) "string"
|
|
||||||
[2]=>
|
|
||||||
string(17) "This is a heredoc"
|
|
||||||
}
|
|
||||||
|
|
||||||
Iteration: 8
|
|
||||||
array(2) {
|
|
||||||
[0]=>
|
|
||||||
string(6) "binary"
|
|
||||||
[1]=>
|
|
||||||
string(6) "binary"
|
|
||||||
}
|
|
||||||
|
|
||||||
Iteration: 9
|
|
||||||
array(1) {
|
array(1) {
|
||||||
[0]=>
|
[0]=>
|
||||||
NULL
|
NULL
|
||||||
}
|
}
|
||||||
|
Iteration: 5
|
||||||
Iteration: 10
|
array(1) {
|
||||||
|
[1]=>
|
||||||
|
bool(false)
|
||||||
|
}
|
||||||
|
Iteration: 6
|
||||||
array(1) {
|
array(1) {
|
||||||
[0]=>
|
[0]=>
|
||||||
NULL
|
string(0) ""
|
||||||
|
}
|
||||||
|
Iteration: 7
|
||||||
|
array(1) {
|
||||||
|
[0]=>
|
||||||
|
string(6) "string"
|
||||||
}
|
}
|
||||||
Done
|
Done
|
||||||
|
|
|
@ -12,15 +12,6 @@ echo "*** Testing array_diff() : usage variations ***\n";
|
||||||
// Initialise function arguments not being substituted (if any)
|
// Initialise function arguments not being substituted (if any)
|
||||||
$array = array(1, 2);
|
$array = array(1, 2);
|
||||||
|
|
||||||
//get an unset variable
|
|
||||||
$unset_var = 10;
|
|
||||||
unset ($unset_var);
|
|
||||||
|
|
||||||
//get heredoc
|
|
||||||
$heredoc = <<<END
|
|
||||||
This is a heredoc
|
|
||||||
END;
|
|
||||||
|
|
||||||
//array of values to iterate over
|
//array of values to iterate over
|
||||||
$values = array(
|
$values = array(
|
||||||
|
|
||||||
|
@ -46,45 +37,23 @@ $values = array(
|
||||||
/*4*/
|
/*4*/
|
||||||
"null" => array(
|
"null" => array(
|
||||||
// null data
|
// null data
|
||||||
NULL,
|
|
||||||
null),
|
null),
|
||||||
|
|
||||||
/*5*/
|
/*5*/
|
||||||
"boolean" => array(
|
"boolean" => array(
|
||||||
// boolean data
|
// boolean data
|
||||||
true,
|
true,
|
||||||
false,
|
false),
|
||||||
TRUE,
|
|
||||||
FALSE),
|
|
||||||
|
|
||||||
/*6*/
|
/*6*/
|
||||||
"empty" => array(
|
"empty" => array(
|
||||||
// empty data
|
// empty data
|
||||||
"",
|
|
||||||
''),
|
''),
|
||||||
|
|
||||||
/*7*/
|
/*7*/
|
||||||
"string" => array(
|
"string" => array(
|
||||||
// string data
|
// string data
|
||||||
"string",
|
'string'),
|
||||||
'string',
|
|
||||||
$heredoc),
|
|
||||||
|
|
||||||
/*8*/
|
|
||||||
"binary" => array(
|
|
||||||
// binary data
|
|
||||||
b"binary",
|
|
||||||
(binary)"binary"),
|
|
||||||
|
|
||||||
/*9*/
|
|
||||||
"undefined" => array(
|
|
||||||
// undefined data
|
|
||||||
@$undefined_var),
|
|
||||||
|
|
||||||
/*10*/
|
|
||||||
"unset" => array(
|
|
||||||
// unset data
|
|
||||||
@$unset_var)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// loop through each element of the array for $arr2
|
// loop through each element of the array for $arr2
|
||||||
|
@ -151,28 +120,4 @@ array(2) {
|
||||||
[1]=>
|
[1]=>
|
||||||
int(2)
|
int(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
Iteration: 8
|
|
||||||
array(2) {
|
|
||||||
[0]=>
|
|
||||||
int(1)
|
|
||||||
[1]=>
|
|
||||||
int(2)
|
|
||||||
}
|
|
||||||
|
|
||||||
Iteration: 9
|
|
||||||
array(2) {
|
|
||||||
[0]=>
|
|
||||||
int(1)
|
|
||||||
[1]=>
|
|
||||||
int(2)
|
|
||||||
}
|
|
||||||
|
|
||||||
Iteration: 10
|
|
||||||
array(2) {
|
|
||||||
[0]=>
|
|
||||||
int(1)
|
|
||||||
[1]=>
|
|
||||||
int(2)
|
|
||||||
}
|
|
||||||
Done
|
Done
|
||||||
|
|
|
@ -35,8 +35,8 @@ $sysroot = exec('echo %SYSTEMROOT%');
|
||||||
$file_handle = popen("$sysroot/system32/sort", "w");
|
$file_handle = popen("$sysroot/system32/sort", "w");
|
||||||
$newline = "\n";
|
$newline = "\n";
|
||||||
foreach($arr as $str) {
|
foreach($arr as $str) {
|
||||||
fwrite($file_handle, (binary)$str);
|
fwrite($file_handle, $str);
|
||||||
fwrite($file_handle, (binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)$newline);
|
fwrite($file_handle, $newline);
|
||||||
}
|
}
|
||||||
pclose($file_handle);
|
pclose($file_handle);
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ $sysroot = exec('echo %SYSTEMROOT%');
|
||||||
$file_handle = popen("$sysroot/system32/sort", "w");
|
$file_handle = popen("$sysroot/system32/sort", "w");
|
||||||
$newline = "\n";
|
$newline = "\n";
|
||||||
foreach($arr as $str) {
|
foreach($arr as $str) {
|
||||||
fwrite($file_handle, (binary)$str);
|
fwrite($file_handle, $str);
|
||||||
fwrite($file_handle, (binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)$newline);
|
fwrite($file_handle, $newline);
|
||||||
}
|
}
|
||||||
pclose($file_handle);
|
pclose($file_handle);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ $n = $tidy->Root()->child[0]->child[1]->child[0];
|
||||||
var_dump($n->isComment());
|
var_dump($n->isComment());
|
||||||
var_dump((string)$n);
|
var_dump((string)$n);
|
||||||
var_dump((bool)$n);
|
var_dump((bool)$n);
|
||||||
var_dump((double)$n);
|
var_dump((float)$n);
|
||||||
var_dump((int)$n);
|
var_dump((int)$n);
|
||||||
var_dump($tidy->Root()->child[0]->child[0]->hasSiblings());
|
var_dump($tidy->Root()->child[0]->child[0]->hasSiblings());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue