tree: drop non canonical casts and ZPP tests

This commit is contained in:
Gina Peter Banyard 2025-08-05 14:05:24 +01:00
parent 14034ad734
commit 1e0c8baf05
No known key found for this signature in database
GPG key ID: F30F8C1ACF51943F
24 changed files with 75 additions and 1122 deletions

View file

@ -5,12 +5,12 @@ zend.assertions=1
assert.exception=1
--FILE--
<?php
var_dump((integer)ini_get("zend.assertions"));
var_dump((int)ini_get("zend.assertions"));
ini_set("zend.assertions", 0);
var_dump((integer)ini_get("zend.assertions"));
var_dump((int)ini_get("zend.assertions"));
assert(false);
ini_set("zend.assertions", 1);
var_dump((integer)ini_get("zend.assertions"));
var_dump((int)ini_get("zend.assertions"));
assert(true);
var_dump(true);
?>

View file

@ -5,7 +5,7 @@ precision=14
--FILE--
<?php
$doubles = array(
$floats = array(
076545676543223,
032325463734,
0777777,
@ -13,8 +13,8 @@ $doubles = array(
033333333333333,
);
foreach ($doubles as $d) {
$l = (double)$d;
foreach ($floats as $d) {
$l = (float)$d;
var_dump($l);
}

View file

@ -105,7 +105,7 @@ MySQLPDOTest::skip();
test_type($db, 90, 'MEDIUMINT UNSIGNED', 16777215, ($is_mysqlnd) ? 16777215 : '16777215');
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);
test_type($db, 110, 'INT UNSIGNED', 4294967295, ($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? 4294967295 : '4294967295') : '4294967295');

View file

@ -114,15 +114,15 @@ class Extract_Phar
{
$fp = fopen(__FILE__, 'rb');
fseek($fp, self::LEN);
$L = unpack('V', $a = (binary)fread($fp, 4));
$m = (binary)'';
$L = unpack('V', $a = (string)fread($fp, 4));
$m = '';
do {
$read = 8192;
if ($L[1] - strlen($m) < 8192) {
$read = $L[1] - strlen($m);
}
$last = (binary)fread($fp, $read);
$last = (string)fread($fp, $read);
$m .= $last;
} while (strlen($last) && strlen($m) < $L[1]);
@ -268,7 +268,7 @@ class Extract_Phar
$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)");
}

View file

@ -2,7 +2,7 @@
date_default_timezone_set('UTC');
$manifest = (binary)'';
$manifest = '';
$glags = 0;
foreach($files as $name => $cont)
@ -34,12 +34,12 @@ foreach($files as $name => $cont)
if (empty($comp)) $comp = $cont;
if (empty($ulen)) $ulen = strlen($cont);
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);
// write manifest entry
$manifest .= pack('V', strlen($name)) . (binary)$name;
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta;
$manifest .= pack('V', strlen($name)) . $name;
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . $meta;
// globals
$gflags |= $flags;
@ -50,13 +50,13 @@ if (!isset($alias)) $alias = 'hio';
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;
$file = (binary)$file;
$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . $alias . pack('V', strlen($pmeta)) . $pmeta . $manifest;
$file = $file;
$file .= pack('V', strlen($manifest)) . $manifest;
foreach($files as $cont)
{
$file .= (binary)$cont;
$file .= $cont;
}
file_put_contents($fname, $file);

View file

@ -5,7 +5,7 @@ ini_set('date.timezone', 'GMT');
$tname = basename(current(get_included_files()), ".php");
$fname = dirname(__FILE__) . "/$tname.phar.php";
$pname = 'phar://' . $fname;
$file = (binary)'<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
$files = array();

View file

@ -2,7 +2,7 @@
date_default_timezone_set('UTC');
$manifest = (binary)'';
$manifest = '';
$gflags = 0;
foreach($files as $name => $cont)
@ -34,12 +34,12 @@ foreach($files as $name => $cont)
if (empty($comp)) $comp = $cont;
if (empty($ulen)) $ulen = strlen($cont);
if (empty($clen)) $clen = strlen($comp);
if (empty($crc32))$crc32= crc32((binary)$cont);
if (empty($crc32))$crc32= crc32($cont);
$meta = isset($meta) ? serialize($meta) : "";
// write manifest entry
$manifest .= pack('V', strlen($name)) . (binary)$name;
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta;
$manifest .= pack('V', strlen($name)) . $name;
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . $meta;
// globals
$gflags |= $flags;
@ -50,13 +50,13 @@ if (!isset($alias)) $alias = 'hio';
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;
$file = (binary)$file;
$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . $alias . pack('V', strlen($pmeta)) . $pmeta . $manifest;
$file = $file;
$file .= pack('V', strlen($manifest)) . $manifest;
foreach($files as $cont)
{
$file .= (binary)$cont;
$file .= $cont;
}
file_put_contents($fname, $file);

View file

@ -108,16 +108,16 @@ class danger_tarmaker
$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)) {
stream_copy_to_stream($fileOrStream, $this->tmp);
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 {
fwrite($this->tmp, (binary)$fileOrStream);
fwrite($this->tmp, $fileOrStream);
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));
}
}
}

View file

@ -3,7 +3,7 @@ include dirname(__FILE__) . '/tarmaker.php.inc';
class corrupter extends tarmaker {
function close()
{
fwrite($this->tmp, (binary)'oopsie');
fwrite($this->tmp, 'oopsie');
fclose($this->tmp);
}
}

View file

@ -107,16 +107,16 @@ class tarmaker
$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)) {
stream_copy_to_stream($fileOrStream, $this->tmp);
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 {
fwrite($this->tmp, (binary)$fileOrStream);
fwrite($this->tmp, $fileOrStream);
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));
}
}
}

View file

@ -25,8 +25,8 @@ var_dump((bool)$foo);
var_dump((bool)$people);
var_dump((int)$foo);
var_dump((int)$people);
var_dump((double)$foo);
var_dump((double)$people);
var_dump((float)$foo);
var_dump((float)$people);
var_dump((string)$foo);
var_dump((string)$people);
var_dump((array)$foo);

View file

@ -11,8 +11,8 @@ var_dump($xml->number);
$int = $xml->number / 1024 / 1024 / 1024;
var_dump($int);
$double = (double) $xml->number / 1024 / 1024 / 1024;
var_dump($double);
$float = (float) $xml->number / 1024 / 1024 / 1024;
var_dump($float);
?>
--EXPECT--
object(SimpleXMLElement)#2 (1) {

View file

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

View file

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

View file

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

View file

@ -10,10 +10,6 @@ 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
{
@ -22,11 +18,6 @@ class classA
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
//array of different data types to be passed to $arr1 argument
$inputs = array(
@ -50,50 +41,28 @@ $inputs = array(
// null data
/*3*/
'null' => array(
NULL,
null),
// boolean data
/*4*/
'bool' => array(
true,
false,
TRUE,
FALSE),
false),
// empty data
/*5*/
'empty' => array(
"",
''),
// string data
/*6*/
'string' => array(
"string",
'string',
$heredoc),
// binary data
/*7*/
'binary' => array(
b"binary",
(binary)"binary"),
'string'),
// object data
/*8*/
'object' => array(
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
@ -135,65 +104,33 @@ array(5) {
}
-- Iteration 3 --
array(2) {
array(1) {
[0]=>
NULL
[1]=>
NULL
}
-- Iteration 4 --
array(3) {
array(1) {
[1]=>
bool(false)
[2]=>
bool(true)
[3]=>
bool(false)
}
-- Iteration 5 --
array(2) {
array(1) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
-- Iteration 6 --
array(3) {
array(1) {
[0]=>
string(6) "string"
[1]=>
string(6) "string"
[2]=>
string(11) "hello world"
}
-- Iteration 7 --
array(2) {
[0]=>
string(6) "binary"
[1]=>
string(6) "binary"
}
-- Iteration 8 --
array(1) {
[0]=>
object(classA)#%d (0) {
}
}
-- Iteration 9 --
array(1) {
[0]=>
NULL
}
-- Iteration 10 --
array(1) {
[0]=>
NULL
}
Done

View file

@ -11,15 +11,6 @@ echo "\n*** Testing array_diff_assoc() : usage variations ***\n";
$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
$inputs = array(
@ -31,48 +22,15 @@ $inputs = array(
12345 => 'positive',
-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
/*5*/
'empty' => array(
"" => 'emptyd',
'' => 'emptys'),
'' => 'empty'),
// string data
/*6*/
'string' => array(
"string" => 'stringd',
'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'),
'string' => 'strings'),
);
@ -104,48 +62,12 @@ array(4) {
-- Iteration 2 --
array(1) {
[""]=>
string(6) "null 2"
string(5) "empty"
}
-- Iteration 3 --
array(2) {
[1]=>
string(5) "boolT"
[0]=>
string(5) "boolF"
}
-- Iteration 4 --
array(1) {
[""]=>
string(6) "emptys"
}
-- Iteration 5 --
array(2) {
["string"]=>
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

View file

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

View file

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

View file

@ -12,15 +12,6 @@ echo "*** Testing array_diff() : usage variations ***\n";
// Initialise function arguments not being substituted (if any)
$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
$values = array(
@ -46,51 +37,25 @@ $values = array(
/*4*/
"null" => array(
// null data
NULL,
null),
/*5*/
"boolean" => array(
// boolean data
true,
false,
TRUE,
FALSE),
false),
/*6*/
"empty" => array(
// empty data
"",
''),
"empty" => array(''),
/*7*/
"string" => array(
// 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)
"string" => array('string'),
);
// loop through each element of the array for arr1
$iterator = 1;
foreach($values as $value) {
echo "\n Iteration: $iterator \n";
echo "Iteration: $iterator\n";
var_dump( array_diff($value, $array) );
$iterator++;
};
@ -99,11 +64,9 @@ echo "Done";
?>
--EXPECT--
*** Testing array_diff() : usage variations ***
Iteration: 1
array(0) {
}
Iteration: 2
array(3) {
[0]=>
@ -113,7 +76,6 @@ array(3) {
[3]=>
int(-2345)
}
Iteration: 3
array(5) {
[0]=>
@ -127,58 +89,24 @@ array(5) {
[4]=>
float(0.5)
}
Iteration: 4
array(2) {
array(1) {
[0]=>
NULL
[1]=>
NULL
}
Iteration: 5
array(2) {
array(1) {
[1]=>
bool(false)
[3]=>
bool(false)
}
Iteration: 6
array(2) {
array(1) {
[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) {
[0]=>
NULL
}
Iteration: 10
array(1) {
[0]=>
NULL
string(6) "string"
}
Done

View file

@ -12,15 +12,6 @@ echo "*** Testing array_diff() : usage variations ***\n";
// Initialise function arguments not being substituted (if any)
$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
$values = array(
@ -46,45 +37,23 @@ $values = array(
/*4*/
"null" => array(
// null data
NULL,
null),
/*5*/
"boolean" => array(
// boolean data
true,
false,
TRUE,
FALSE),
false),
/*6*/
"empty" => array(
// empty data
"",
''),
/*7*/
"string" => array(
// 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)
'string'),
);
// loop through each element of the array for $arr2
@ -151,28 +120,4 @@ array(2) {
[1]=>
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

View file

@ -35,8 +35,8 @@ $sysroot = exec('echo %SYSTEMROOT%');
$file_handle = popen("$sysroot/system32/sort", "w");
$newline = "\n";
foreach($arr as $str) {
fwrite($file_handle, (binary)$str);
fwrite($file_handle, (binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)$newline);
fwrite($file_handle, $str);
fwrite($file_handle, $newline);
}
pclose($file_handle);

View file

@ -35,8 +35,8 @@ $sysroot = exec('echo %SYSTEMROOT%');
$file_handle = popen("$sysroot/system32/sort", "w");
$newline = "\n";
foreach($arr as $str) {
fwrite($file_handle, (binary)$str);
fwrite($file_handle, (binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)$newline);
fwrite($file_handle, $str);
fwrite($file_handle, $newline);
}
pclose($file_handle);

View file

@ -19,7 +19,7 @@ $n = $tidy->Root()->child[0]->child[1]->child[0];
var_dump($n->isComment());
var_dump((string)$n);
var_dump((bool)$n);
var_dump((double)$n);
var_dump((float)$n);
var_dump((int)$n);
var_dump($tidy->Root()->child[0]->child[0]->hasSiblings());